Unstring Feature

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

Unstring Feature

Post by tony_smith » Wed Apr 07, 2004 8:26 pm

Each time I see our Cobol programmers parsing with abandon, I wish I had a similar facility in MSched.

They have a command that works like this, for example... with a delimited file as in EDI applications...

UNSTRING SPLIT-IN-REC DELIMITED BY ELEMENT-SEPARATOR
INTO LINE-SEG(1) LINE-SEG(2)
LINE-SEG(3) LINE-SEG(4)
LINE-SEG(5) LINE-SEG(6)
LINE-SEG(7) LINE-SEG(7)

This would be a real time saver for parsing files; instead of using Readln/Position/Midstr/Writeln loops, use a line "unstring" command.

Any chance of getting such an enhancement?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Apr 07, 2004 9:54 pm

Have you checked out what you can do with Separate> ?

From the Help file:
Separate>list,delimiter,returnvar

Separate takes a list, a delimiter and returns the elements of the list. The command returns a number of variables, one for each list element, each with the suffix "_n" where n is the index of the element in the list. The variable names are determined by the name given in returnvar. e.g. returnvar_1, returnvar_2, etc. Also returned is the number of elements in the list, in returnvar_count.

Abbreviation : SEP

Example

GetFileList>c:\temp\*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%

Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

Duuuhhh... on me!

Post by tony_smith » Thu Apr 08, 2004 2:19 pm

Of course! I have been using SEP for years, but only in the file list routine... which I have copied/pasted into many scripts, but I was never really conscious of the what was going on within the two lines (GFL/SEP) It never really came to mind that I should explore SEP.

I have some parse routines that seem to run forever, so I will give SEP a whack when I have a chance... see if I can save some time.

Thanks for pointing this out, Bob :oops:

Tony

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