adding lines to a file

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
alanimal
Junior Coder
Posts: 40
Joined: Thu Jun 09, 2005 11:57 pm

adding lines to a file

Post by alanimal » Tue Dec 08, 2009 7:43 pm

Hi all,

I have a file which staff will open in notepad, then add their own line and save. The problem is - they tend to stuff things up. The format of the file is below - it has a header followed by the data. It is a csv but uses a .sb extension.

BASE,100,DRIVERS,100,6,29/08/2002 9:04,29/08/2002 9:04.
Depot number,User number,Name,Balance,Closing Balance,Date,
35464,Priyanka Kumari,0,0,NO DATA,NO DATA,
37165,Laura Hopkinson,0,0,NO DATA, NO DATA,
12942,Vivien Yang,0,0,NO DATA, NO DATA,

What I would like to do - is create an app that would prompt the user for the data, the user would enter the data via a series of message boxes - then it would be written to the file in the above format. this would save allot of headaches and I am sure it wouldnt be too hard? The 2 first parameters need to be entered by staff and the rest can be hard coded.

Any help would be appreciated.

Cheers!

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

Post by JRL » Tue Dec 08, 2009 9:31 pm

Try something like this. Be sure to assign a proper value to the "filename" variable and make sure to modify the writeln> string and dialog to create what you actually want.

Code: Select all

Let>filename=The path and name of your file
Let>comma=,

Dialog>Dialog1
   Caption=Dialog1
   Width=433
   Height=223
   Top=151
   Left=26
   Button=Save,172,148,75,25,3
   Edit=msEdit1,47,42,322,
   Edit=msEdit2,49,96,320,
   Label=Depot Number,48,24
   Label=Name,48,80
   Default=Save
EndDialog>Dialog1

Show>Dialog1

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  If>res1=3
    GoSub>Process
  EndIf
  Wait>0.01
Goto>Loop

SRT>Process
  WriteLn>filename,wres,%Dialog1.msedit1%%comma%%Dialog2.msedit1%%comma%0%comma%0%comma%NO DATA%comma%NO DATA
  Exit>0
END>Process

alanimal
Junior Coder
Posts: 40
Joined: Thu Jun 09, 2005 11:57 pm

Post by alanimal » Wed Dec 09, 2009 1:27 am

thanks mate - exactly what I am after - problem is that as you can see the below 2 lines are not writing the name correctly - I cant see an error so not sure whats happening - any ideas?

13970,Raeoni Jackson,0,0,NO DATA,NO DATA,
32331,%Dialog2.msedit1%,0,0,NO DATA,NO DATA
34234,%Dialog2.msedit1%,0,0,NO DATA,NO DATA

Thanks in advance - appreciate your help

alanimal
Junior Coder
Posts: 40
Joined: Thu Jun 09, 2005 11:57 pm

Post by alanimal » Wed Dec 09, 2009 1:29 am

agh sorted - should be

WriteLn>filename,wres,%Dialog1.msedit1%%comma%%Dialog1.msedit2%%comma%0%comma%0%comma%NO DATA%comma%NO DATA

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

Post by JRL » Wed Dec 09, 2009 3:14 am

Sorry about that. Did a copy and paste then changed the wrong "1" to a "2". I know better than to post without testing but I was in a hurry to get home before the big snow storm started here in Iowa. Glad you got it figured out.

alanimal
Junior Coder
Posts: 40
Joined: Thu Jun 09, 2005 11:57 pm

Post by alanimal » Wed Dec 09, 2009 3:24 am

cheers mate. Snow storm eh? ouch - will you be out there once its cleared with your skis?

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

Post by JRL » Wed Dec 09, 2009 6:05 am

I'm not much on winter sports. We don't usually get this much snow at once. Its hard to tell for sure because of the drifting but I'm guessing we've gotten a foot of snow in the last 8 hours.

No need to clog the forum with this talk though. If you'd like to discuss the weather you can PM me though I may be too busy shoveling tomorrow to answer :shock:

Glad the script worked for you.

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