String Manipulation

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
CZ
Newbie
Posts: 18
Joined: Wed Feb 07, 2007 7:51 am

String Manipulation

Post by CZ » Tue Mar 06, 2007 7:23 am

Hello I am new to using the Macro Scheduler 9.0
I had used the evaluation version and have just gotten the
Pro version. This is a very good program, but I am very new to scripting and programming. I have been trying to figure out how to do this for a while. I have looked at all the forums and help files and not quite grasping how to do this.

The items listed below are in a notepad text file:

@C:\My Stuff\Data\quicken 99 deluxe edition\every use backup - 02/20/07 1402
@C:\My Stuff\Data\quicken 99 deluxe edition\every use backup1 - 03/01/07 0920
C:\My Stuff\Data\quicken 99 deluxe edition\every use backup2 -

What I am trying to do is find the "C:\My Stuff\Data\quicken 99 deluxe edition\every use backup" without the "@" preceding it. I then would copy the "C:\My Stuff\Data\quicken 99 deluxe edition\every use backup" portion of the line and paste it to another program. I would then put a "@" in front of the "C:\My Stuff\Data\quicken 99 deluxe edition\every use backup" in the same line and then time and date stamp it at the end of the line like the first 2 entries seen above. When all 3 of the "C:\My Stuff\Data\quicken 99 deluxe edition\every use backup" have a "@" then I would like to delete all 3 "@" in front of the "C:\My Stuff\Data\quicken 99 deluxe edition\every use backup" as well as the time and date stamp at the end of the lines. I would then do a search for the "C:\My Stuff\Data\quicken 99 deluxe edition\every use backup" portion of the line and do as stated before. I can't figure out how to be able to capture and copy "C:\My Stuff\Data\quicken 99 deluxe edition\every use backup". I would like to be able to use the notepad text file that I have these items in to manipulate the strings.

I have tried to do some scripting. This is the best I could come up with. I would appreciate any help.

Let>k=1

Label>start
Wait>.5
ReadLn>C:\Documents and Settings\Cal\My Documents\Financial Goals.txt,k,line
Position>C:\My Stuff\Data\quicken 99 deluxe edition\every use backup,%Line%,1,r1,TRUE
If>Position>{(C:\My Stuff\Data\quicken 99 deluxe edition\every use backup)}=1,finish

If>line=##EOF##,finish

Let>k=k+1

Goto>start

Label>finish
Message>DONE.

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

Post by Marcus Tettmar » Tue Mar 06, 2007 7:56 am

Some untested psuedo-code:

Code: Select all

ReadLn>filename,k,line
Pos>@,line,1,p
If>p=1
  //this line starts with @, so just write it to new file
  WriteLn>newfile,r,line
else
  Pos> -,line,1,p
  Let>p=p-1
  MidStr>line,1,p,path
  //Paste %path% to other program ...

  //need some code to count consecutive @ and create counter 
  //if path same as last, increment counter ...

  //Now add the @ and date
  Day>dy
  Month>mh
  Year>yr
  Hour>hr
  Min>mn
  Let>newline=@%path% - %mh%/%dy%/%yr% %hr%%mn%
  //write to new file
  WriteLn>newfile,r,line
Endif

//at end, delete input filename, and move newfile to old file
DeleteFile>filename
MoveFile>newfile,filename
Not final code. Just something to get you started and give you some ideas.

When modifying a text file you actually read from the original file, write out to a new file and then delete the old file, and rename the new to the old afterwards ... easiest and safest.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

CZ
Newbie
Posts: 18
Joined: Wed Feb 07, 2007 7:51 am

Post by CZ » Tue Mar 06, 2007 5:15 pm

Thank You for your quick response. I'll try that.

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