Problems Using GetArrayVariable in VBScript
BE from United States  [12 posts]
1 year
I can't seem to get GetArrayVariable in a VBScript to work.  I suppose there is some Dim or ReDim required, but I'm not sure.  Refer to the attached screen shot of the VBScript module dialog box.  The user variable Pad1 is cearly an array as shown in the "Available Variables" list box, but I can't get it to be read into a VBScript array.

The isArray function says the variable junk is an array, but ubound returns -1 and any attempt to access an element of junk gives an error.

BE from United States  [12 posts] 1 year
Ah, I discovered that there are two things causing problems...

1) The variables in question were created using the Read_Variables module, which handles the file contents quite differently when data is in columns vs. rows.  While the variables dialog box in the VBScript Program module showed comma separated values, all those numbers and commas were actually part of a single string.  The VBScript variables dialog does not show variable type (integer, string, etc.) so this was not apparent until I looked at the variables with Watch Variables which does display type.

2) Apparently you cannot use GetArrayVariable to read into the same VB variable twice in the same context.  By splitting up my calls to GetArrayVariable into separate contexts, the problem was solved.
Steven Gentner from United States  [260 posts] 1 year

1. Thanks for the investigation. Yes, the Read_Variables module was actually created BEFORE arrays were even possible within RR (its an old module) so it would default to creating a string. We could update that but I fear that we might break many existing RR configurations that have been written to expect a string. Perhaps we may add an option in that interface to select string or array which would solve the issue for new configurations.

Thus using a GetStrVariable and a Split would achieve the same array effect.

2. Not sure if we can replicate this issue. I've attached a test robofile ... perhaps you can tweak it to replicate the way you are using it?

Ideally, just use the GetVariable function once and save a copy of the array into another variable before changing the first ...


This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index