Parsing problem with Separate

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Parsing problem with Separate

Post by mightycpa » Mon Jan 12, 2004 8:01 pm

Hi,

I query from a db using VBScript, and place a record in the return variable. I've tried a couple of delimiters, ~ and ; but I get the same results.

Here is the offending code, pretty much stripped off the help file:


MessageModal>%Record%

GetFileList>Record,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>List item %k% -> file_names_%k% -->file_names_1
Until>k,file_names_count



In the message modal box #1, Record is correctly displayed. Each element in Record has a value, by the way

In the message modal box #2, The number of parsed elements is correct

In the message (and message modal BTW) box, the variable substitution doesn't seem to occur... in other words, instead of the value of
file_names_1, I get the literal string "file_names_1". I get it for both attempts, file_names_%k% and file_names_1.

I'm probably doing something stupid here, but I can't see what it is...

Tx,

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

I found a couple of things

Post by mightycpa » Mon Jan 12, 2004 8:25 pm

I found that this code from above:


MessageModal>%Record%

GetFileList>Record,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>List item %k% -> file_names_%k% -->file_names_1
Until>k,file_names_count



should not use GetFileList, so I changed it to


MessageModal>%Record%

Separate>Record,;,elements
MessageModal>Num Elements: %elements_count%

Let>k=0
Repeat>k
Let>k=k+1
MessageModal>List item %k% %CRLF% Method 1 -> elements_%k% %CRLF% Method 2 --> elements_1 %CRLF% Method 3 --> %elements_1%
Until>k,2


But it yields the same results for Methods 1 and 2; Method 3 returns the correct value within the variable.

So if I want to dynamically work with the value based on the separation index, how in the world do I do this? Must I "hardcode" the index a la Method 3?


Tx,

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Jan 13, 2004 8:48 am

Hi,

If that code is in the help file then it is wrong. You need to put file_names_%k% into a simple variable before displaying it in a message box with other text. As follows:

GetFileList>Record,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Let>thefile=file_names_%k%
Message>List item %k% -> %thefile%
Until>k,file_names_count
MJT Net Support
[email protected]

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Kewl!

Post by mightycpa » Tue Jan 13, 2004 2:51 pm

Yeah, the "file_names_%k%" is in there alright. I thought it looked a little funny. I will try your approach, makes sense, I appreciate it.

Tx,

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Still missing something

Post by mightycpa » Tue Jan 13, 2004 4:53 pm

Your solution worked but it is still ..... I could use a little more robust solution, specifically, to place the values in an array.

I tried this:


Repeat>k
Let>k=k+1
Let>the_element=elements_%k%
Let>RValue[%k%]=the_element
MessageModal>List item %k% %CRLF%
the_element is %the_element% %CRLF%
RValue is RValue[%k%]
Until>k,5


But using the above, the RV variable displays the literal value
"RV is RValue[n]" where n equals the current value of k in the loop.

Basically, I've got a lot of stuff to do with each of the various elements, and I would prefer that the Repeat Loop does nothing more than assign the variables. Also, I would like it to be dynamic, (ie, the same code can handle a 5 column SELECT statement or a 100 column SELECT statement).

Any suggestions?

Tx,

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Jan 13, 2004 5:03 pm

Hi,

The problem is only with displaying the values in the message box. Your variables are actually fine. It's just that to display them in the message box you have to simplify them. You probably don't even need the message box. If you want to step through to see it working use the debugger. Enable Show Watchlist and use F8 - set the cursor on the top line and F8 from line to line and you will see the values of the variables.

Your confusion lies only in your attempt to display the array variables in a message box within other strings.
MJT Net Support
[email protected]

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Thanks.

Post by mightycpa » Tue Jan 13, 2004 5:11 pm

Gotcha -

I added this to my script:


MessageModal>RValue[%k%]
MessageModal>elements_%k%



and both worked like a charm. This is the part that is missing in your help file, I would suggest the addition of a warning that displaying array values with text will prevent the value from displaying, and that the workaround is to assign the values to a static variable.

I understand now.

Tx,

George
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts