Author Topic: Documentation for 'parse' built-in?  (Read 7995 times)

dmw

  • Senior Community Member
  • Posts: 145
  • Hero Points: 15
Documentation for 'parse' built-in?
« on: July 25, 2006, 08:01:21 PM »
The documentation page for the parse builtin (ie. parse a with x ', ' y ', ' z) appears to have vanished at some point, or is at least very well hidden.  I know I've seen it before because I remember reading that its non-C-like syntax was a holdover from when REXX was SlickEdit's macro language.  But I can't seem to find it in the online help, nor in any of the printed manuals I have (going back to 1998).  Anyone know where I might have seen it?  If someone has it somewhere, could you post a copy here?

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Documentation for 'parse' built-in?
« Reply #1 on: July 25, 2006, 08:10:00 PM »

I reported this to slickedit support a week or two ago and they said they'll add it back to the help.
Here's a copy from V8 slick help.

Graeme


parse

parse string with template


Remarks   When we converted our REXX style language to C-style, we had to leave the syntax of this statement alone because there was no reasonable way to represent this statement as a function.

   This statement parses string as specified by template.

   Template may contain


variable_name   Output variable
.   Null output variable
nnn   Number specifying new parse column
+nnn   Amount to increment parse column relative to start of last string found or last column setting.
-nnn   Amount to decrement parse column relative to start of last string found or last column setting.
'text'[,search_options]
   String constant to search for.  If found, parse column becomes first character after text.  Otherwise parse column becomes first character after length of string being parsed.  search_options is an optional expression that may evaluate to a string of one or more of the option letters U, R, I, and Y.  U specifies UNIX regular expressions.  R specifies SlickEdit regular expressions.  B specifies Brief regular expressions.  I specifies a case insensitive search.  Y specifies a binary which search allows positions in the middle of a DBCS character (only effects Japanese operating systems).  See Regular Expressions.

(expression)[,search_options]
   String expression to search for.  If found, parse column becomes first character after text.  Otherwise parse column becomes first character after length of string being parsed.  See above for a description of the search options.


   Rules for parse column


·   The parse column is initialized to column 1
·   If a column or column increment specifies a column greater than the length of the string being parsed, the parse column is set to the length of the string being parsed plus one.
·   If a column decrement specifies a column less than the length of the string being parsed, the parse column is set to column 1.


   Rules for setting output variables


·   Output variables are set in groups.  An output variable group is defined to be consecutive variables with no search or column specifiers between them.

·   Before variables of an output variable group can be set, the end parse column within the source string must be found.  In the case the end parse column is set by a search, the end parse column for this output variable group becomes the first character to the left of the text found.  In the case the end parse column is set by a column or column increment the end parse column becomes the first character to the left of the column.  The start parse column is the current parse column as specified by the template.


·   A word parse of the text between the start and end columns is performed to set the variables in an output variable group if the group contains more that one variable.  Otherwise the one output variable is set to the text between the start and end columns of the source string.  Each variable set by a word parse will have no leading or trailing tabs/spaces except for the last output variable which is set to the rest of the sub-string.

·   If the start column is greater than the end column the variables in the output group are set to null.


   Examples
         parse '1 2 3' with a b c;
         // Results are  a=='1', b=='2', c=='3'
   
         parse '1 '\t' 2 '\t' 3' with a b c;
         // Results are  a=='1', b=='2', c=='3'.  Note that tab and space characters are stripped.
   
         parse '1 2 3' with a . b;
         // Results are  a=='1', b=='3'

         parse 'xxx1 2 3yyy 4 5' with 'xxx' a b c 'yyy' d e;
         // Results are  a=='1', b=='2', c=='3', d=='4', e=='5'

         parse 'xxx1 2 3yyy 4 5' with 'xxx' a  'yyy' b;

         // Results are  a=='1 2 3', b==' 4 5'

         parse 'xxx1 2 3yyy 4 5' with 'xxx' +0 a  'yyy' +0 b;
         // Results are  a=='xxx1 2 3', b=='yyy 4 5'

         parse 'c/x/y' with  1 delim +1 s1 (delim) s2 (delim) options;
         // Results are delim=='/', s1=='x', s2=='y', options==''





dmw

  • Senior Community Member
  • Posts: 145
  • Hero Points: 15
Re: Documentation for 'parse' built-in?
« Reply #2 on: July 25, 2006, 08:21:36 PM »
That's the one.  Thanks for the speedy reply.