/*
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%
User Designed Seperate Function
Moderators: JRL, Dorian (MJT support)
User Designed Seperate Function
Just thought I'd try to help.
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%
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
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?
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.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
The script works fine for me:
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.
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%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
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.
Got any other ideas why this may be occurring.
Thanks anyone.
Just thought I'd try to help.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
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?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?