Script Syntax Question for all

Moderator: Moderator Group

Script Syntax Question for all

Postby chrisr » Fri Nov 11, 2016 5:03 pm

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!
Thank You

ChrisR
SurfacePro3 - 2GHz i5 - 4GB ram - Windows 10 Pro - WD Pro 4.7 Rev2500 and WD v6
Sager Laptop - Intel 2.4GHz i7 3630QM - 16GB ram - Windows 7 Pro Svc Pack1 - Offline Manager v6
chrisr
 
Posts: 143
Joined: Tue Jan 26, 2016 10:50 pm

Re: Script Syntax Question for all

Postby chrisr » Sun Nov 13, 2016 9:16 pm

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!
Thank You

ChrisR
SurfacePro3 - 2GHz i5 - 4GB ram - Windows 10 Pro - WD Pro 4.7 Rev2500 and WD v6
Sager Laptop - Intel 2.4GHz i7 3630QM - 16GB ram - Windows 7 Pro Svc Pack1 - Offline Manager v6
chrisr
 
Posts: 143
Joined: Tue Jan 26, 2016 10:50 pm

Re: Script Syntax Question for all

Postby Dennis Kuypers » Mon Nov 14, 2016 11:56 am

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
Dennis Kuypers
(former Product Developer, Software)
Dennis Kuypers
coolux Germany
 
Posts: 771
Joined: Thu Jul 05, 2012 12:18 pm


Return to Widget Designer V4.7

Who is online

Users browsing this forum: No registered users and 20 guests