July 2, 200322 yr 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.
October 16, 200322 yr 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 Steve (I've attached a sample file ) Parse.zip
Create an account or sign in to comment