Convice this array script to work
travis
Posts: 180
DEFINE_CONSTANT INTEGER test1[] = {1,2} INTEGER test2[] = {3,4} INTEGER testa[2][2] = { test1, test2 } DEFINE_VARIABLE VOLATILE INTEGER testi = 1 VOLATILE INTEGER testb[2] DEFINE_START for(testi=1;testi<=2;testi++) { testb[testi] = testa[testi][1] }
I think the part that dies is INTEGER testa[2][2] = { test1, test2 }
It shows up blank in the debug window.
0
Comments
Change your variable
VOLATILE INTEGER testi = 1
to
INTEGER testi = 1
or
NON_VOLATILE INTEGER testi = 1
I once was trying to test out a very basic chunk of code and I could not get it to work. the cause was the couple variables I was using were all VOLATILE and the master likes to have at least 1 non-volatile variable in the system.
I hope this helps
--John
This is only true for debugging the code. If you don't have a non-volatile variable, the debugger complains about the source code not matching what's on the processor. It still runs fine.
Nope, no initializers allowed in define_start
The example at the top is not my whole program, just snippets to get the point across
If that doesn't work, try moving testa to the define_variable section. You might also have to do a define_start population of the array to get it initialized.
Jeff
I just defined a constant using a constant and it worked for an integer (learn something new every day). I agree that the problem is in the way the testa array is initialized though.
--John
HBO = {300, 15} //first number is satellite channel #, second the number of the button
ABC = {290, 66}
All_the_networks = { HBO, ABC, etc...}
All_the_channel_numbers = function to pull first item out of each network array, out of all_the_networks [300, 290]
All_the_buttons = function for second item [15,66]
button_event[tp, all_the_buttons]
get_last[all_the_buttons]
etc...
don't blame the wonky button number => tv channel mapping on me. I'm just updating (rewriting) some axcess code (written by a mean bad person)
I guess you need change it to a variable and initialize somewhere else.
I hate using them, but would this not be a great time to use a STRUCTURE? Can you even use a structure's value for button events? I've never tried....
You cant really use a structure in a get_last but if you make the TP channels number the index position of the structure and have the structuer hold the actual TV channel you could something like this:
DEVCHAN has everything a BUTTON_EVENT requires: a device (DEV) and a channel (INTEGER). I'm just confused as to why it wouldn't work. If you made a structure like so:
STRUCTURE ChanLineup
{
INTEGER ChannelNumber
INTEGER ButtonNumber
}
BUTTON_EVENT[dvTP,ChanLineup.ButtonNumber] - or however you do it.
Wouldn't that work?
Would you show an example of how you implimented the get_last por favor.
Pushing buttons 2,4,6,8 produces the following:
Results:
Maybe it only works when the structure is equivelent to a 1 dimension array?
I decided to restructure the structure similar to Joe's structure and what do ya know this works but the above way doesn't. Either way the structure is formed would work for my needs, although I'm not actually using any of this code but typically I would format the structure as I originally did above and it wouldn't even had occurred to me to structure the structure the way I did below.
How would other folks normally create this type of structure if not using it as in this code with a get_last? As I did above or as I did below?
Again forgive all the set_length_array.
results:
Does this also work if the structure is an array?
--D
The last three SET_LENGTHs aren?t legal for a couple of different reasons. First you need to address an element in the sCATV array before you can set the length of (or peek or poke) any of the members inside the structure. So you need to start off with something like this:
The second set length is trying to set the length of CH_NUM to 100 which doesn?t fly since CH_NUM is a straight INTEGER. So SET_LENGTH_ARRAY need not apply.
The line: is not legal since it needs to start with something like this: and the number can?t be greater than 12 since that?s the max length that was defined.
Same logic goes for the last SET_LENGTH_ARRAY.
The last two SET_LENGTHs aren?t needed because the length is getting set by the direct assignment in the FOR loop. But if you did want to manually set the length of the members inside the array then you would have to address an individual element in the sCATV array as stated above.
When I create s STRUCT the prototype is for a unit of 1 so I would go with your first example also.
I hope I didn?t muddy the waters.
It does but as you probably guessed you would have to setup the event like this.
And then another button event like this:
You can’t put an array of arrays inside an event, struct or not.
I highly recommend structures but as I stated in an earlier post, I normally use simple button arrays for button events.
You can use a struct inside a button event and get_last will work but I don’t know how practical it is.
I'm going with this.
I made a spreadsheet that has all the channels and button numbers, and then made another column that combines them that I can just paste into netlinx (after stripping out all the carriage returns and adding a } to the end).
Using the spreadsheet, will you be converting it to CSV, and then uploading it somewhere for the processor to download and parse? That would be helpful in the event a channel changes!
Maybe I could make a program where I drop all the IR files on it, and it does everything for me except draw the buttons!
Why not have it "draw" the buttons too? You could create 100 blank buttons on a page and have the processor "draw" them as needed
Jeff
It's very doable - in fact taught in P3.
Joe Hebert wrote: I actually like Muddy Waters, James Cotton ......