[DONE] Writing to a file from a stringgadet
Posted: Sat Apr 03, 2010 4:10 pm
Hello,
I have a stringgadget in my window, and i want to take the input from it and write it to a file.
I am not sure how to go about this.
I have tried this:
and this is the in the main loop:
The file gets created, but nothing is written in it?
I have a stringgadget in my window, and i want to take the input from it and write it to a file.
I am not sure how to go about this.
I have tried this:
Code: Select all
Procedure Open_Window_1()
If OpenWindow(#Window_1, 308, 114, 391, 76, "New window ( 1 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_1))
StringGadget(#String_0, 20, 10, 340, 30, newlander$)
ButtonGadget(#Button_3, 290, 50, 70, 20, "add")
EndIf
EndIf
EndProcedure
Code: Select all
ElseIf GadgetID = #Button_3
; add a landing page to the list
If OpenFile(0, "Landers.dat") ; opens an existing file or creates one, if it doesn't exist yet
FileSeek(0, Lof(0)) ; jump to the end of the file (result of Lof() is used)
WriteStringN(0, newlander$)
CloseFile(0)
EndIf