Jump to content

Recommended Posts

Posted

i need help with this save function i want my button to save as i guess you can call it

 

 

 

while 1
   $msg=GUIGetMsg()
   if $msg=-3 Then Exit
      If $msg=$Save Then Save()
      WEnd

 Func Save ()
    $var = FileSaveDialog( "Choose a name.", @DesktopCommonDir , "File (*.RTF;*.TXT)", 2)
    If Not @error Then
    If StringRight(StringUpper($var),4) = ".RTF" Then
    SaveFile($var)
    ElseIf StringRight(StringUpper($var),4) = ".TXT" Then
    SaveFile($var)
    Else
    SaveFile($var & ".RTF")
    EndIf
    EndIf
   FileChangeDir ( @ScriptDir ) ;Look Her
EndFunc

 

 

----------------------------------------------------

This is the whole script i got so far

The Edit box is working good

and so is the Open box when i open a text file it opens it up and sticks in there. wich is exactly wut i want. but if i have to make modifcations to this PLZ let me know.

Need to get this darn Save button to work been at this for awhile been on google. googling the heck out of this baby. been at the manual reading and reading. you know feels like im just missing a few things. thx in advance.

 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 442, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 433, 305)

$Open = GUICtrlCreateButton("Open", 8, 328, 75, 25, $WS_GROUP)
$Save = GUICtrlCreateButton("Save", 160, 328, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

 

while 1
   $msg=GUIGetMsg()
   if $msg=-3 Then Exit
      If $msg=$Open Then Open()
      WEnd

      Func Open ()
         $message = ("Click Shift to Select Multiple files.")
         $var = FileOpenDialog ($message, @DesktopCommonDir & "\" , "Lists (*.txt)")
         $file = Fileread($var)
         If @error Then
            MsgBox (0, "", "No File(s) were selected")
         Else
            GUICtrlSetData($edit1, $file)
         EndIf
      EndFunc

while 1
   $msg=GUIGetMsg()
   if $msg=-3 Then Exit
      If $msg=$Save Then Save()
      WEnd

 Func Save ()
    $var = FileSaveDialog( "Choose a name.", @DesktopCommonDir , "File (*.RTF;*.TXT)", 2)
    If Not @error Then
    If StringRight(StringUpper($var),4) = ".RTF" Then
    SaveFile($var)
    ElseIf StringRight(StringUpper($var),4) = ".TXT" Then
    SaveFile($var)
    Else
    SaveFile($var & ".RTF")
    EndIf
    EndIf
   FileChangeDir ( @ScriptDir ) ;Look Her
EndFunc

Posted
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 625, 442, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 0, 0, 433, 305)

$Open = GUICtrlCreateButton("Open", 8, 328, 75, 25, $WS_GROUP)
$Save = GUICtrlCreateButton("Save", 160, 328, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

HotKeySet("{ESC}", "Quit")


Global $var

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Save
            Save()
        Case $Open
            Open()
    EndSwitch

WEnd

Func Open()
    $message = ("Click Shift to Select Multiple files.")
    $var = FileOpenDialog($message, @DesktopCommonDir & "\", "Lists (*.txt)", $FD_MULTISELECT)
    $file = FileRead($var)
    If @error Then
        MsgBox(0, "", "No File(s) were selected")
    Else
        GUICtrlSetData($Edit1, $file)
    EndIf
EndFunc   ;==>Open

Func Save()

    $var = FileSaveDialog("Choose a name.", @DesktopCommonDir, "(*.TXT)|(*.RTF)", $FD_PATHMUSTEXIST + $FD_PROMPTOVERWRITE)
    If Not @error Then
        $sRead = GUICtrlRead($Edit1)
        FileWrite($var, $sRead)
    EndIf

;~  FileChangeDir(@ScriptDir) ;Look Her
EndFunc   ;==>Save

Func Quit()
    Exit
EndFunc   ;==>Quit

 

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

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
  • Recently Browsing   0 members

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