Jump to content

Recommended Posts

Posted

hello

 

I am comming back on to scripting after several years out.

and i am a bit glued with the problem of passing an array of words to a function in Target script.

 

I finally fond the way to have it with an array of characters like

{'a', 'b', 'c' }

 

you need to call it that way e.g. to acces second element of the list :

my_func(2, &my_array);

 

and you have to describe your func that way :

int my_func(int i, alias my_array){..   // you ref to it with      &my_array+i  ....}

 

But HOW TO pass / call words array like {"cat", "dog", "crazy squirrell" ...} ?

 

With C langage you have pointers, their type is defined, same as arrays type.

 

BUT in TARGET SCRIPT we have that specious < ALIAS >

What is the way to do it with ALIAS ?

Can you define types ? and How to ?

 

Or is Target limited to single arrays and not of words ?

 

If you use previous syntax with words array you don't point to "cat" content, but you receive a character that is strange and a single one. I suppose there is a problem with types and the +i pointer not jumping bytes long enough be at the good location in memory...

 

Any ideas ? any way having that working ?:cry:

 

because in need crazy squirrels in my Hotas ! indeed !!!!:smilewink:

Posted (edited)

some ideas to prgress, but need help

 

searching from all the afternoon, and finally looking at target /include folder with target.tmh and hid.tmh, found the way :

 

define SIZEMYWORD 13*6+1
define SIZEMYARRAY 5*SIZEMYWORD      
struct array_MsgTrim { char str_MsgTrimDirection[sizeMYARRAY]; }
array_MsgTrim str_MsgSay_Trim = {"Trim up ", "Trim down ", "Trim left ", "Trim right "};

 

- but I need help : compile error < Array/struct bounds overflow >

my numbers should be wrong, I need help on how to calculate it for my array

 

EDIT :have it compiling htat way, but more precise calculations appreciated :

define KTRIMWORDLEN				13*6+1
define MAXKTRIMWORDLEN		5*KTRIMWORDLEN
struct array_MsgTrim { char str_MsgTrimDirection[KTRIMWORDLEN]; }
array_MsgTrim str_MsgSay_Trim[MAXKTRIMWORDLEN] = {"Trim up ", "Trim down ", "trim left ", "trim right "};

 

 

- then correct syntax to refer to the words in a function call and inside the called function...

Edited by C6_Hellfrog
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...