Jump to content
Sign in to follow this  
D4rk^S0ul

Saving test from gui text box

Recommended Posts

D4rk^S0ul

$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?

Share this post


Link to post
Share on other sites
Jos

$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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
D4rk^S0ul

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

Share this post


Link to post
Share on other sites
Jos

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
seandisanti

$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...

Share this post


Link to post
Share on other sites
D4rk^S0ul

#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

Share this post


Link to post
Share on other sites
Jos

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 Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
D4rk^S0ul

Thanks ;) works gr8

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  

×