Jump to content
Server Maintenance This Week. ×

Troi Dialog, How to Parse the Result?


This topic is 7512 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I have been playing around with the Troi Dialog plug-in, using a 5 field input dialog box.

The result is a string, broken up by |

All of the results will be of different lengths. So, I am getting in a muddle in trying to split the long text into its 5 component pieces.

Link to comment
Share on other sites

  • 3 months later...

Hey;

You can also parse the results quite easily with a few short scripts. Assuming you are using TroiDialog the seperation character is the pipe

symbol ----> | but this procedure can be used to extract results from

any kind of delimited thingy.

Just using TROI as an example, the inputdialog function returns something like this: 1|smallthing|alargerthing|bob

To begin, just add a | to the end of the result with the following:

Set Field: _Gresult = _Gresult &"|"

This will result in the following: 1|smallthing|alargerthing|bob

As you probably know with TROI the first item is the button number pressed. Extract that SetField: _GButtonPress = left(_Gresult,1)

Secondly, to parse the variable length contents from _Gresult and assuming the seperator is the | symbol, use this:

Set Field: Parsed1 =

Middle(_Gresult,

Position(_Gresult,"|",1,1)+1,

Position(_Gresult,"|",1,2)-

Position(_Gresult,"|",1,1)-1)

To get the next value, simply increment the reference to which "|" to look for like this:

Set Field: Parsed2 =

Middle(_Gresult,

Position(_Gresult,"|",1,2)+1,

Position(_Gresult,"|",1,3)-

Position(_Gresult,"|",1,2)-1)

Set Field Parsed3 =

Middle(_Gresult,

Position(_Gresult,"|",1,3)+1,

Position(_Gresult,"|",1,4)-

Position(_Gresult,"|",1,3)-1)

Very simply this script does the following: Set the field of Parsed_whatever to the "Middle Text" between positions 1 and 2 (or 2 and 3 / 3 and 4, etc) It calculates the length of the text by deteriming the positions of the pipe symbols, and subtracting them. Importantly though, the +1 and -1 that you see in the script set the middle text to the desired results WITHOUT including the pipe symbols. If you take out the +1 and -1 then the parsed result would look like: |smallthing| instead of the desired result: smallthing

Now finally, the reason why the first step is to add a "|" to the end of _gresult is so that this script can easily identify the last input. If _Gresult doesn't end with a "|" then it won't work.

Hope this helps smile.gif

Steve

(I've attached a sample file )

Parse.zip

Link to comment
Share on other sites

This topic is 7512 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.