Sign in to follow this  
Followers 0
NegativeNrG

how to save WHOLE txt file to txt file?

6 posts in this topic

#1 ·  Posted (edited)

Im working on my Text Editor and i dont know how to save the WHOLE text written in the EDIT box.

heres my Sample code:

$Form1 = GUICreate("Simple Text v0.1", 477, 299, 199, 129)
$Edit1 = GUICtrlCreateEdit("", 8, 32, 465, 249, -1, $WS_EX_CLIENTEDGE)
GUIctrlsetdata($Edit1,"")
$menu = GUIctrlcreatemenu("File")
$item1 = GUIctrlcreatemenuitem("Open",$menu)
$item = GUIctrlcreatemenuitem("Save As..",$menu)
GUISetState(@SW_SHOW)

While 1
       $msg = GUIgetmsg()
        Select
     Case $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $item
[b]$save = FileSaveDialog("Save To..","C:\","Text Documents(*.txt)",16)[/b]
FileWrite($save,$Edit1)

In Bold it doesnt work, ive tried FileWriteline, but also doesnt work. Can anyone help me?

Edited by NegativeNrG

[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites



$Form1 = GUICreate("Simple Text v0.1", 477, 299, 199, 129)
$Edit1 = GUICtrlCreateEdit("", 8, 32, 465, 249, -1, $WS_EX_CLIENTEDGE)
GUIctrlsetdata($Edit1,"")
$menu = GUIctrlcreatemenu("File")
$item1 = GUIctrlcreatemenuitem("Open",$menu)
$item = GUIctrlcreatemenuitem("Save As..",$menu)
GUISetState(@SW_SHOW)

While 1
       $msg = GUIgetmsg()
        Select
     Case $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $item
$ReadEdit = GuiCtrlRead($Edit1)
$save = FileSaveDialog("Save To..","C:\","Text Documents(*.txt)",16)
FileWrite($save,$ReadEdit)


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Doh!, should have thought of that first..forgot all about GUictrlread()


[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

ok i have another problem, When i open up a .Txt File in my Text Editor, i Then Deleted the words, then wrote something, saved it, but then it doesnt save, it does but...Read example.

i have a Text document with the words "hello" in it, i then delete the words hello, then write testing, but when i save it, it says hellotesting. anyone help?


[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

Try this!

#Include<GuiConstants.au3>

$FORM1 = GUICreate("Simple Text v0.1", 477, 299, 199, 129)

$EDIT1 = GUICtrlCreateEdit("", 8, 32, 465, 249, -1, $WS_EX_CLIENTEDGE)

GUICtrlSetData($EDIT1, "")

$MENU = GUICtrlCreateMenu("File")

$ITEM1 = GUICtrlCreateMenuItem("Open", $MENU)

$ITEM = GUICtrlCreateMenuItem("Save As..", $MENU)

GUISetState(@SW_SHOW)

While 1

$MSG = GUIGetMsg()

Select

Case $MSG = $GUI_EVENT_CLOSE

ExitLoop

Case $MSG = $ITEM

$SAVE = FileSaveDialog("Save To..", "C:\", "Text Documents(*.txt)", 16)

FileOpen($SAVE, 2)

FileWrite($SAVE, GUICtrlRead($EDIT1))

FileClose($SAVE)

Case $MSG = $ITEM1

$OPEN = FileOpenDialog("Open..", "C:\", "Text Documents(*.txt)", 16)

GUICtrlSetData($EDIT1, "")

GUICtrlSetData($EDIT1, FileRead($OPEN, FileGetSize($OPEN)))

EndSelect

WEnd

Share this post


Link to post
Share on other sites

hi psandu.ro,

Thanks, and that worked, im about 1/2 Complete :P.


[size=20]My File Upload[/size]Register at my site and upload.

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