User Designed Seperate Function

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply

Was this useful or redundant

Poll ended at Fri Feb 22, 2008 1:26 am

useful
1
100%
redundant
0
No votes
 
Total votes: 1

Glen717
Newbie
Posts: 3
Joined: Fri Feb 15, 2008 1:13 am
Location: Midland TX

User Designed Seperate Function

Post by Glen717 » Fri Feb 15, 2008 1:26 am

/*
Using MySeparate places the parsed variables into xxx.

Try this function out if your having problems with the Seperate function for whatever reason; in no wise diminishing from the power of Macro Scheduler's built in function.

This code works as is, or modify to make it work the way you want it to. The count will reside in xxx_1. i.e. sending God,is,good will result in xxx_1=3, xxx_2=God, xxx_3=is, and xxx_4=good

I do not yet know how to return a variable or array in Scheduler. This function lacks that ability. If someone would let me know, Ill come back and re-edit this function to include that convenience. Thanks!
*/

SRT>MySeparate
let>sstring=mySeparate_VAR_1
let>sdelim=mySeparate_VAR_2
length>sstring,lenstring
let>atdel=2
Label>AgainDelim
position>%sdelim%,%sstring%,1,presult,false
if>presult=0,DelimFinished
let>presult=presult-1
midstr>sstring,1,presult,newstring
let>xxx_%atdel%=newstring
let>atdel=atdel+1
let>presult=presult+1
let>lenstring=%lenstring%-%presult%
let>presult=%presult%+1
midstr>sstring,%presult%,%lenstring%,sstring
goto>AgainDelim
Label>DelimFinished
let>xxx_%atdel%=sstring
let>xxx_1=atdel-1
END>MySeparate

let>test=Added,counter,to,first,element
let>delim=,
gosub>MySeparate,test,delim
messagemodal>The %xxx_1% strings are: %xxx_2% %xxx_3% %xxx_4% %xxx_5% %xxx_6%
Just thought I'd try to help.

User avatar
JRL
Automation Wizard
Posts: 3529
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Feb 15, 2008 5:24 am

I don't mean to sound stupid but how is this different from the provided Separate function? Does this not provide the same result with a lot less effort?

Code: Select all

let>test=Added,counter,to,first,element
let>delim=,
Separate>test,delim,xxx
messagemodal>The %xxx_count% strings are: %xxx_1% %xxx_2% %xxx_3% %xxx_4% %xxx_5%

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Feb 15, 2008 10:01 am

I can't see that it does anything different. So my vote would be for "redundant". As Dick points out you can do exactly the same with 2 lines of code. What are we missing?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Feb 15, 2008 3:07 pm

I have to agree, I saw it last night and was waiting for one of you gurus to show me what I was missing.

With some modification it could correctly parse a delimited string respecting quoted elements and that would be useful.

Glen717
Newbie
Posts: 3
Joined: Fri Feb 15, 2008 1:13 am
Location: Midland TX

Post by Glen717 » Fri Feb 15, 2008 3:32 pm

OK, it is redundant and it doesn't solve the following problem when reading the following file data into one string; say "readstring"

John Doe/40
Cool Blue/36
Jane Doe/36
Mary Jane/40
Somebody Else/25

then separate it into 5 strings of astring_1 thru astring_5
separate>readstring,%CRLF%,astring

You will note that anytime you set any variable to 40, it is somehow changed to 36 at some point in the loop and no matter where you are later in your code.

astring_1=John Doe/40
astring_2=Cool Blue/36
astring_3=Jane Doe/36
astring_4=Mary Jane/50
astring_5=Somebody Else/25

Let>Parsing=0
Repeat>Parsing
let>Parsing=Parsing+1
separate>astring,/,singlestrings
let>testvar=40
messagemodal>%testvar% //on second or third round shows 36
//and thereafter shows 36 when you set it to 40, one of the variables
//read from both Cool Blue/36 and Jane Doe/36
until>Parsing=5

let>anothertest=40
messagemodal>%anothertest%

//why is anothertest somehow changed to 36 or someother number it was not set to be?
Just thought I'd try to help.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Feb 15, 2008 3:41 pm

The script works fine for me:

Code: Select all

ReadFile>d:\script_support\testlist.txt,readstring
separate>readstring,%CRLF%,astring

Let>Parsing=0
Repeat>Parsing
let>Parsing=Parsing+1
separate>astring_%Parsing%,/,singlestrings
let>testvar=40
messagemodal>%testvar% %singlestrings_1% %singlestrings_2%
//on second or third round shows 36
//and thereafter shows 36 when you set it to 40, one of the variables
//read from both Cool Blue/36 and Jane Doe/36
until>Parsing=5

let>anothertest=40
messagemodal>%anothertest%
I get expected results. What you describe just sounds like you have at some point created a variable called 36 which is set to 40. THen when you refer to 36 on it's own it shows 40, because the variable 36=40. But that doesn't happen in the code you supplied. There's probably a mistake somewhere else in your code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Glen717
Newbie
Posts: 3
Joined: Fri Feb 15, 2008 1:13 am
Location: Midland TX

Post by Glen717 » Fri Feb 15, 2008 7:59 pm

Thank you for checking this procedure out for me, nevertheless I did check to make sure that when I set a variable to 40 it remained at 40. I did this in 3 seperate areas of my code before ever calling this procedure. It was only during the procedure and always thereafter that 40 was changed to 36. And do note that the seperate function is indeed working with these two numbers. I have not worked with these 2 numbers anywhere else in all of my entire code.

Got any other ideas why this may be occurring.

Thanks anyone.
Just thought I'd try to help.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Feb 15, 2008 8:39 pm

Open up the Advanced editor. Step through line by line with F8. Watch the Watch List. Stop when you see "40=36" in the watch list. Now you know where/why it is happening.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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