Sign in to follow this  
Followers 0
adastra23

Writing Form input to text file

3 posts in this topic

I'm writing a GUI to take form information and then save it to a text file.

I'm having trouble with the syntax of @CR or @LF or @CRLF and where it would go in my text.

The output that I am getting is:

*** BEGIN TRANSMISSION ***abcd*** END TRANSMISSION ***

And I would like it to be:

*** BEGIN TRANSMISSION ***

a

b

c

d

*** END TRANSMISSION ***

I am combining script from another forum and here, where I am trying to learn autoit.

http://www.autoitscript.com/forum/index.php?showtopic=47420

CODE

;Need help with carriage return and line feed @CR AND @LF OR @CRLF

#include <GUIConstants.au3>

;new code for the app

GUICreate("Setup Utility", 600, 600)

GUISetFont(10)

GUICtrlCreateLabel("Please Complete the following information:", 4, 4)

GUICtrlCreateLabel ("Name:", 10,30)

GUICtrlCreateLabel ("Address:", 10,80)

GUICtrlCreateLabel ("Zip:", 10,130)

GUICtrlCreateLabel ("More:", 10,180)

; a b c d added for testing, they will be blank

$put1 = GUICtrlCreateInput("a", 100, 30, 200, 25)

$put2 = GUICtrlCreateInput("b", 100, 80, 200, 25)

$put3 = GUICtrlCreateInput("c", 100, 130, 200, 25)

$put4 = GUICtrlCreateInput("d", 100, 180, 200, 100)

$send = GUICtrlCreateButton("send to file - save", 108, 400, 150, 25)

GUISetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

If $msg = $send Then SendMyData()

WEnd

Func SendMyData()

FileDelete('bar.txt')

FileWrite( 'bar.txt', "*** BEGIN TRANSMISSION ***")

$data1 = GUICtrlRead($put1)

$data2 = GUICtrlRead($put2)

$data3 = GUICtrlRead($put3)

$data4 = GUICtrlRead($put4)

FileWrite('bar.txt', $data1 & $data2 & $data3 & $data4)

FileWrite( 'bar.txt', "*** END TRANSMISSION ***")

MsgBox(0,'Saved','Saved to bar.txt')

EndFunc

Any help you can provide would be appreciated,

I have tried putting carrage returns with @LF @CF everywhere I can imagine they would go, but only getting errors.

Thanks.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

FileWrite( 'bar.txt', "*** BEGIN TRANSMISSION ***" & @CRLF)
$data1 = GUICtrlRead($put1)
$data2 = GUICtrlRead($put2)
$data3 = GUICtrlRead($put3)
$data4 = GUICtrlRead($put4)
FileWrite('bar.txt', $data1 & @CRLF & $data2 & @CRLF & $data3 & @CRLF & $data4 & @CRLF)
FileWrite( 'bar.txt', "*** END TRANSMISSION ***")

Edited by poisonkiller

Share this post


Link to post
Share on other sites

I cannot thank you enough. You saved my day. (and believe me, I would have kept working on this for another 3-4 hours.)

I have noticed some people replying with "RTFM" on these forums and the truth is I had searched help and the forums. I couldn't find any reference to @CRLF when it wasn't attached to a string.

I also thank you for not saying "RTFM"

I was missing the ampersand (&) in my trials.

You have taught me, thanks.

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