Jump to content

Saving test from gui text box


D4rk^S0ul
 Share

Recommended Posts

$savetext = GuiCtrlCreateMenu("Save")

$Edit_1 = GUICtrlCreateEdit("", 5, 45, 230, 130)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Case $msg = $savetext
    $edit_2 = GuiCtrlRead($Edit_1)
    $file = FileOpen("test.txt", 1)
    FileWrite($file, $edit_2)

That is my code so far can any1 help me to see what is wrong with this?

Link to comment
Share on other sites

  • Developers

$savetext = GuiCtrlCreateMenu("Save")

$Edit_1 = GUICtrlCreateEdit("", 5, 45, 230, 130)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Case $msg = $savetext
    $edit_2 = GuiCtrlRead($Edit_1)
    $file = FileOpen("test.txt", 1)
    FileWrite($file, $edit_2)

That is my code so far can any1 help me to see what is wrong with this?

<{POST_SNAPBACK}>

This is the whole script ?????????????

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

no thats the example of wat writes the file i dont see why this does not work, i normally get a random number in the file instead of the text

<{POST_SNAPBACK}>

If you have a question it helps when you give a working script and you explain exactly what is going wrong... that saves a lot of "Let guess what his problem is" posts...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

$savetext = GuiCtrlCreateMenu("Save")

$Edit_1 = GUICtrlCreateEdit("", 5, 45, 230, 130)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Case $msg = $savetext
    $edit_2 = GuiCtrlRead($Edit_1)
    $file = FileOpen("test.txt", 1)
    FileWrite($file, $edit_2)

That is my code so far can any1 help me to see what is wrong with this?

<{POST_SNAPBACK}>

Case $msg = $savetext
    $file = FileOpen("test.txt", 1)
    FileWrite($file, GuiCtrlRead($edit_1))
    FileClose($file)
EndSelect

you may have other issues in the script if that's not working, you may want to post a larger listing of the code, atleast all parts that concern variables or statements in segment listed...

Link to comment
Share on other sites

#include <GUIConstants.au3>

Opt("TrayIconHide", 1)

GUICreate("QuickPad",240,180)

$filemenu = GuiCtrlCreateMenu ("File")
$fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu)
$recentfilesmenu = GuiCtrlCreateMenuitem ("Recent Files:",$filemenu)
$fileexit = GuiCtrlCreateMenuItem ("Exit",$filemenu)
$savetext = GuiCtrlCreateMenu("Save")

$Edit_1 = GUICtrlCreateEdit("", 5, 45, 230, 130)

GUISetState()

While(1)
    
    $msg = GUIGetMsg() 
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $fileexit
            Exitloop
        
        Case $msg = $savetext
            $edit_2 = GuiCtrlRead($Edit_1)
            $file = FileOpen("test.txt", 1)
            FileWrite($file, GuiCtrlRead($edit_1))
            FileClose($file)
        
        Case $msg = $fileitem
            $file = FileOpenDialog("Choose file...",@TempDir,"(*.txt)")
            If @error <> 1 Then GuiCtrlCreateMenuItem ($file,$recentfilesmenu)
                
        
    EndSelect
    
Wend

This isent goin to be a used program ;) just for my own learning really.

Edited by D4rk^S0ul
Link to comment
Share on other sites

  • Developers

Case $msg = $savetext is never true because $savetext is not a MenuItem...

Try:

#include <GUIConstants.au3>

Opt("TrayIconHide", 1)

GUICreate("QuickPad",240,180)

$filemenu = GuiCtrlCreateMenu ("File")
$fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu)
$recentfilesmenu = GuiCtrlCreateMenuitem ("Recent Files:",$filemenu)
$fileexit = GuiCtrlCreateMenuItem ("Exit",$filemenu)
$savetext = GUICtrlCreateMenuitem("Save",-1)

$Edit_1 = GUICtrlCreateEdit("", 5, 45, 230, 130)

GUISetState()

While(1)
    
    $msg = GUIGetMsg() 
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $msg = $fileexit
            Exitloop
        
        Case $msg = $savetext
            $edit_2 = GuiCtrlRead($Edit_1)
            $file = FileOpen("test.txt", 1)
            FileWrite($file, GuiCtrlRead($edit_1))
            FileClose($file)
        
        Case $msg = $fileitem
            $file = FileOpenDialog("Choose file...",@TempDir,"(*.txt)")
            If @error <> 1 Then GuiCtrlCreateMenuItem ($file,$recentfilesmenu)
                
        
    EndSelect
    
Wend

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...