And just when I got all excited...
ericmedley
Posts: 4,177
I was goofing around with a new program and tried this:
... wondering if this would work. And lo and behold, it compiled just fine!
I was hoping it would populate the first cell with a '7'
Finally, the secret to my uniform code at last! I can simply keep adding or subtracting touch panels and my arrays grow and shrink with them. However, in debug I found out that it doesn't actually work. The array gets built by 1 dimention in that cell. :P
DEFINE_DEVICE dv_AW_TP_Nav_01 = 10001:01:0 // Game Room 5" Wireless dv_AW_TP_Nav_02 = 10002:01:0 // Kevin's Room 5" In Wall dv_AW_TP_Nav_03 = 10003:01:0 // Living Room 5" Wireless dv_AW_TP_Nav_04 = 10004:01:0 // Kitchen 5" Wireless dv_AW_TP_Nav_05 = 10005:01:0 // Study 4" In Wall dv_AW_TP_Nav_06 = 10006:01:0 // Guest Apt 5" In Wall dv_AW_TP_Nav_07 = 10007:01:0 // Master Bed 5" Wireless DEFINE_VARIABLE volatile DEV dev_AW_TP_01[]= { dv_AW_TP_Nav_01 // Game Room 5" Wireless ,dv_AW_TP_Nav_02 // Kevin's Room 5" In Wall ,dv_AW_TP_Nav_03 // Living Room 5" Wireless ,dv_AW_TP_Nav_04 // Kitchen 5" Wireless ,dv_AW_TP_Nav_05 // Study 4" In Wall ,dv_AW_TP_Nav_06 // Guest Apt 5" In Wall ,dv_AW_TP_Nav_07 // Master Bed 5" Wireless } // and here it is... volatile AW_TV_POPUP_NAME[length_array(dev_AW_TP_01)][200][40]
... wondering if this would work. And lo and behold, it compiled just fine!
I was hoping it would populate the first cell with a '7'
Finally, the secret to my uniform code at last! I can simply keep adding or subtracting touch panels and my arrays grow and shrink with them. However, in debug I found out that it doesn't actually work. The array gets built by 1 dimention in that cell. :P
0
Comments
I always just use a constant such as nMAX_TP to define lengths of variables - and if we add one touch panel I essentially make 2 changes: one to the TP array, the other to the constant that says how big it is.
... yeah, i know... (* huff *)
Here's my goal...
I can?t believe the compiler didn?t freak when you put a function call inside the square brackets of a multidimensional array declaration. I think you took the compiler by surprise and exposed a bug. I sure would like to know what the compiler was thinking when it let that go without barfing.
I didn?t get any semblance of a multidimensional array when I tried it (yeah, I had to try it ). All I got was a one byte null.
Same here.
I do something similar and it seems to work fine. What are the problems you are having?
Paul
You put a function call inside the square brackets of a multidimensional array declaration and it worked?
Can you post an example? I?d love to see what I?ve been missing and then proceed to eat crow.
I can't find the piece of code I wrote at the moment, but what I think I did was pass an array of TPs to a module, and then in define_start of that module, get the length of the array, and then immediately after that do a set_length_array on the array that is defined in the module using the result from length_array. I don't know what you need this for, but I was using it to make sure an the array declared in the module was the same length of an array that was passed into the module.
Paul
Exactly. For example, the thing that I was doing was a big giant TV control array. I wanted to make it possible to control an enormous number of TVs and any number of TPs without writing any additional code. All I need to do is decalre the TPs and list the TV models and control method and be done.
I honestly didn't know if it would work or not. I just gave it a try and noticed that when I hit compile it went through. It even worked in testing for a short while. However, that was because I was only working on TV#1 and Touch Panel#1. When I tried TV#2, I noticed it wasn't working. That's when I discovered the folly of my ways.
SET_LENGTH_ARRAY(ModuleArray,LENGTH_ARRAY(dvTPs))
However, that isn’t remotely close to what the original posted code was attempting to do in the declaration. I’ll save the crow for now, I’m sure I’ll need it later.
Edit: And as already pointed out, you can't set the length to a value greater than the original length declared.
http://science.howstuffworks.com/9-things-invented-or-discovered-by-accident.htm
Yeah, but I can't get my boss to spring for Cafe Duet. He feels that NetLinx is adequate for programming purposes, and frankly, given the track record with some of the Duet modules, it's not an unjustified position. The bottom line is we won't be migrating to Java any time soon, if at all.