Page 1 of 1

Script Syntax Question for all

PostPosted: Fri Nov 11, 2016 5:03 pm
by chrisr
Hello,
I'm am working to write a small script and use some variables with addition. This would keep me from writing over 200 individual lines of script to accomplish what I'm trying to do. Is this script possible? Using the variables inside the NodeSetParam script is where I am running into issues. I know using a single variable is possible, but is adding MATH to it (to the var) within the script possible? I know we can use single quotes around the variables with math for doing direct command, I was curious if it follows over to inserting them into scripts. Here is an example of what I'm trying.

dmx_offset = DMX_Start
Node_ct = 0

For 1 to 20
WDNodeSetParam,Math [1+'Node_ct'],3,Math [0+'dmx_offset']
WDNodeSetParam,Math [2+'Node_ct'],3,Math [2+'dmx_offset']
WDNodeSetParam,Math [3+'Node_ct'],3,Math [4+'dmx_offset']
WDNodeSetParam,Math [4+'Node_ct'],3,Math [6+'dmx_offset']
WDNodeSetParam,Math [5+'Node_ct'],3,Math [7+'dmx_offset']
Node_ct += 5
dmx_offset +=8
Next

Thanks for any input, I do appreciate it. Have a great weekend everyone!

Re: Script Syntax Question for all

PostPosted: Sun Nov 13, 2016 9:16 pm
by chrisr
I couldn't get the Math to work within the scripts, so I just took it out, and used a Integer Var and incremented the value at each line of script.

dmx_offset = DMX_Start
Node_ct = 1

For 1 to 20

WDNodeSetParam,Node_ct,3,dmx_offset
dmx_offset += 2
Node_ct += 1
WDNodeSetParam,Node_ct,3,dmx_offset
dmx_offset += 2
Node_ct += 1
WDNodeSetParam,Node_ct,3,dmx_offset
dmx_offset += 2
Node_ct += 1
WDNodeSetParam,Node_ct,3,dmx_offset
dmx_offset += 1
Node_ct += 1
WDNodeSetParam,Node_ct,3,dmx_offset
dmx_offset += 1
Node_ct += 1

Next

If anyone knows of a better way of doing this, I'm all ears. This was a pretty simple solution, was just trying ( for learning purposes ) to do this efficiently. Thanks!! Have a great week!

Re: Script Syntax Question for all

PostPosted: Mon Nov 14, 2016 11:56 am
by Dennis Kuypers
Hello,

As far as i know you can nest for loops. That might reduce the number of lines a bit.
Code: Select all
dmx_offset = DMX_Start
Node_ct = 1

For 1 to 20

For 1 to 3
innerfor = for.index
WDNodeSetParam,Node_ct,3,dmx_offset
dmx_offset += 2
Node_ct += 1
Next

For 1 to 2
WDNodeSetParam,Node_ct,3,dmx_offset
dmx_offset += 1
Node_ct += 1
Next
Next


Another interesting technique:
Code: Select all
' Assuming integer variables "innerfor" and "outerfor" exist:
For 1 to 5
outerfor = for.index
For 1 to 2
innerfor = for.index
WdMessageBox,outerfor,innerfor
Next
Next


Regards
Dennis