Variable through a module?
dmurray14
Junior Member
I am trying to pass a variable into a function. In the mainline I have:
Then I have my module included:
My module signature:
However, if in the code I do something like:
The mainline variable doesn't get updated. Shouldn't it?
And the module variable doesn't seem to reflect what the mainline variable is, either. What am I doing wrong?
Thanks,
Dan
CHAR myNewVariable[] = '5000';
Then I have my module included:
DEFINE_MODULE 'MyModule' MyMod(myNewVariable[])
My module signature:
MODULE_NAME ='MyModule' (theVariable[])
However, if in the code I do something like:
theVariable = '10000';
The mainline variable doesn't get updated. Shouldn't it?
And the module variable doesn't seem to reflect what the mainline variable is, either. What am I doing wrong?
Thanks,
Dan
Comments
-
In instances like these, you'd be better off associating the variable with LEVEL or a COMMAND.
For instance:DEFINE_DEVICE vdvVirtual= 34001:01:0 SEND_LEVEL vdvVirtual, 1, myNewVariable //or SEND_COMMAND vdvVirtual, "'VARIABLE = ', ITOA(myNewVariable)"
And then have a LEVEL_EVENT in the module or create a COMMAND event.
Good luck! -
I am trying to pass a variable into a function. In the mainline I have:
CHAR myNewVariable[] = '5000';
Change to this: CHAR myNewVariable[10] = '5000';
Then I have my module included:DEFINE_MODULE 'MyModule' MyMod(myNewVariable[])
My module signature:MODULE_NAME ='MyModule' (theVariable[])
change this to: MODULE_NAME ='MyModule' (Char theVariable[])
However, if in the code I do something like:theVariable = '10000';
The mainline variable doesn't get updated. Shouldn't it?
And the module variable doesn't seem to reflect what the mainline variable is, either. What am I doing wrong?
Thanks,
Dan
Try that and it should work. I have passed variables and them seem to update with no problems. If this still doesn't work, let me know and I will research it a little further as this could affect some of my modules.
Jeff -
dmurray14 wrote:
My module signature: Code: MODULE_NAME ='MyModule' (theVariable[])
You need to declare your variable type. Since it isn't delcared as a CHAR array it thinks it's INTEGER array. If it was an integer in your main that would probably be fine but you shoud get in the habit declaring them just for clarity sake.MODULE_NAME ='MyModule' (CHAR theVariable[])
It's not Vegas so what happens in the module doesn't stay in the module and changes should be reflected in your main code.
Edit..
You also don't need the braces after the var array in your module declaration.Then I have my module included: Code: DEFINE_MODULE 'MyModule' MyMod(myNewVariable[]) DEFINE_MODULE 'MyModule' MyMod(myNewVariable)
I don't know if it hurts but it isn't required. I would think it wouldn't compile w/ them but I guess it does. They are required in your module header though because there your declaring the variable type! -
Thanks guys! As usual, you are all so helpful...
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums
