Sign in to follow this  
Followers 0
Senach

Filewrite and user inputs

4 posts in this topic

Greetings all.

I know this is a foolish question, but this is the first programming of any type Ive done since basic on my Apple IIe :)

Anyway, what Im doing is having info put into a series of fields and then Im wanting to write them into a single line of a text file so it harvested by another program. Heres what I have:

$file = FileOpen("C:\scripts\test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, $loc1 " , "$start1 " , "$loc1a" , "$start1a" , "$end1a" , "$loc1b" , "$start1b" , "$end1b" , "$end1 & @CRLF)
FileWrite($file, "nextline" & @CRLF)
FileWrite($file, "lastline")

FileClose($file)

When I run it I get an Error in expression message. I know its just something stupid Im missing, but I cant find an example in the help files or here on the forum to show me how to do something like this.

Any help would be greatly appreciated.

Thank you.


"The three rules of the Librarians of Time and Space are: 1) Silence; 2) Books must be returned no later than the date last shown; and 3) Do not interfere with the nature of causality." Terry Pratchett - The Light Fantastic

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Greetings all.

I know this is a foolish question, but this is the first programming of any type I’ve done since basic on my Apple IIe :)

Anyway, what I’m doing is having info put into a series of fields and then I’m wanting to write them into a single line of a text file so it harvested by another program. Here’s what I have:

When I run it I get an “Error in expression” message. I know it’s just something stupid I’m missing, but I can’t find an example in the help files or here on the forum to show me how to do something like this.

Any help would be greatly appreciated.

Thank you.

You need the append operator "&" between every string and variable (note the syntax for breaking over a line with the underscore "_"):

FileWrite($file, $loc1 & " , " & $start1 & " , " & $loc1a & " , " & $start1a & " , " & $end1a & _
        " , " & $loc1b & " , " & $start1b & " , " & $end1b & " , " & $end1 & @CRLF)

:P

Edit: Oops, missed one...

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thank you! I knew I was just something simple I was overlooking! It works like a charm now!

*bow*


"The three rules of the Librarians of Time and Space are: 1) Silence; 2) Books must be returned no later than the date last shown; and 3) Do not interfere with the nature of causality." Terry Pratchett - The Light Fantastic

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0