bobheart Posted September 11, 2004 Share Posted September 11, 2004 Could someone help me with this ? I don't know how to make it read from a file and how I can edit the txt when it is in the editbox and save it back to the file . expandcollapse popup#cs - ### Generated by AutoBuilder 0.4 -- do not modify ### 394 206 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 tab $tab_1 Tab 1 10 30 260 150 0 0 tabitem $tabitem_1 Tabitem 1 0 0 0 0 0 0 tabitem $tabitem_2 Tabitem 2 0 0 0 0 0 0 edit $edit_1 Edit 1 20 60 230 110 0 0 tabitem -99 -99 1 1 button $button_1 Button 1 300 100 70 20 0 0 #ce - ### End of Dump ### ;Script generated by AutoBuilder 0.4 Opt("GUICoordMode", 1) Opt("GUINotifyMode", 1) GuiCreate("MyGUI", 392,201,(@DesktopWidth-392)/2, (@DesktopHeight-201)/2 , 0x04CF0000) $file = FileOpen("sometxt.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file) $tab_1 = GUISetControl("tab", "Tab 1", 10, 30, 260, 150) $tabitem_1 = GUISetControl("tabitem", "Tabitem 1", 0, 0, 0, 0) $tabitem_2 = GUISetControl("tabitem", "Tabitem 2", 0, 0, 0, 0) $edit_1 = GUISetControl("edit", "Edit 1", 20, 60, 230, 110) $button_1 = GUISetControl("button", "Save", 300, 100, 70, 20) $tab_close = GUISetControl("tabitem","",-99,-99,1,1) ;close tab GuiShow() While 1 sleep(100) $msg = GuiMsg(0) Select Case $msg = -3 Exit Case $msg = 1 ;;; Case $msg = $tab_1 ;;; Case $msg = $tabitem_1 ;;; Case $msg = $tabitem_2 ;;; Case $msg = $edit_1 FileRead =("sometxt.txt") Case $msg = $button_1 ;; EndSelect WEnd Exit Link to comment Share on other sites More sharing options...
ezzetabi Posted September 11, 2004 Share Posted September 11, 2004 I didn't test, but your Select/Case seems well structurated. So you just need to use $text = FileRead('sometxt.txt',FileGetSize('sometxt.txt')) And use GUIWrite ( $edit_1 ,0 ,$text ) for seeing the text and finally use $text = GUIRead ($edit_1) FileWrite('destination.txt',$text) for saving. Hope it helps, but I guess it is not what you meant... Link to comment Share on other sites More sharing options...
bobheart Posted September 11, 2004 Author Share Posted September 11, 2004 I see what your saying but I'm not sure where to put what you gave me to use . Need a little help where it should go . thank you for the help . Link to comment Share on other sites More sharing options...
ezzetabi Posted September 11, 2004 Share Posted September 11, 2004 (edited) This will help, I hope. As you can see the file is read when you click on any of the tabs. And the edit control reset (the first line uses a '' to remove old text) When you press Save you create the file. expandcollapse popupOpt("GUICoordMode", 1) Opt("GUINotifyMode", 1) GuiCreate("MyGUI", 392,201,(@DesktopWidth-392)/2, (@DesktopHeight-201)/2 , 0x04CF0000) $file = FileOpen("sometxt.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileClose($file) $tab_1 = GUISetControl("tab", "Tab 1", 10, 30, 260, 150) $tabitem_1 = GUISetControl("tabitem", "Tabitem 1", 0, 0, 0, 0) $tabitem_2 = GUISetControl("tabitem", "Tabitem 2", 0, 0, 0, 0) $edit_1 = GUISetControl("edit", "Edit 1", 20, 60, 230, 110) $button_1 = GUISetControl("button", "Save", 300, 100, 70, 20) $tab_close = GUISetControl("tabitem","",-99,-99,1,1);close tab GuiShow() While 1 sleep(100) $msg = GuiMsg(0) ; tooltip($msg & @lf & @lf & '$tab_1 = '& $tab_1 & @lf & '$tabitem_1 = ' & $tabitem_1 & @lf & '$tabitem_2 = ' & $tabitem_2 & @lf & ' $edit_1 = ' & $edit_1 & @lf &' $button_1 = ' & $button_1 & @lf &'$tab_close = ' & $tab_close ) ;Uncomment this line if you want to see the $msg values ;and maybe understand better where put code.;) Select Case $msg = -3 Exit Case $msg = 1 ;;; Case $msg = $tab_1 $text = FileRead('sometxt.txt',FileGetSize('sometxt.txt')) GUIWrite ( $edit_1 ,0 ,'' ) GUIWrite ( $edit_1 ,0 ,$text ) Case $msg = $tabitem_1 ;;; Case $msg = $tabitem_2 ;;; Case $msg = $edit_1 ;;; Case $msg = $button_1 $text = GUIRead ($edit_1) FileWrite('destination.txt',$text) EndSelect WEnd Exit Edited September 11, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
bobheart Posted September 11, 2004 Author Share Posted September 11, 2004 Thank you kind sir . i think I understand now that I can see it . I jusy had to change one line and it saves the file now . FileWrite('sometxt.txt',$text) FileWrite('destination.txt',$text) Link to comment Share on other sites More sharing options...
ezzetabi Posted September 11, 2004 Share Posted September 11, 2004 Maybe you have to delete the old file before saving if you use the same filename or it will happend the new text to the old one. Link to comment Share on other sites More sharing options...
bobheart Posted September 11, 2004 Author Share Posted September 11, 2004 Yes I just saw that .. lol I see if I can figure that out . if not I'll give a yell . Link to comment Share on other sites More sharing options...
bobheart Posted September 11, 2004 Author Share Posted September 11, 2004 I just did this and it seemsd to work fine is this ok ? Case $msg = $button_1 FileDelete("sometxt.txt") $text = GUIRead ($edit_1) FileWrite('sometxt.txt',$text) Link to comment Share on other sites More sharing options...
ezzetabi Posted September 12, 2004 Share Posted September 12, 2004 It seems so. Link to comment Share on other sites More sharing options...
bobheart Posted September 12, 2004 Author Share Posted September 12, 2004 Thnk you for the help . I know I can be a pest , but I do try to make things work before I ask for help . Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now