Jump to content

Search the Community

Showing results for tags 'global variable'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I've whittled down a program to illustrate where my problem is. I've been staring at the code and simply am missing something that when I see it pointed out to me will be a DUH moment. On line 14 I declare $file a Global and init it to null "". Line 37 has a Case $idFileMenu_Open where I invoke $file = FileOpenDialog at line 52. When I return to the Case statement $file is null ("") instead of a filename. Running the program (and selecting any .txt file) will message out the $file value at each point. Any comments welcome as I'm stumped ;author: ahha - not so bright :( ;file: Open File issue v1e.au3 #AutoIt3Wrapper_run_debug_mode=Y ;use this to debug in console window <--- LOOK, ;RECALL ;debug will toggle it on/off so use: ; debug if needed Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration #include <File.au3> #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #include <WindowsConstants.au3> Global $data = "" Global $file = "" ;is the full path filename like 'C:\Program Files (x86)\AutoIt3\...\123.txt' Global $cIDFormTextEditorTitle = "* Untitled" ;init value ;==== set up the GUI and the Edit control ==== Global $hFormTextEditor = GUICreate($cIDFormTextEditorTitle, 920, 570, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX), $WS_EX_CLIENTEDGE) ;handle Global $cIDTextEdit = GUICtrlCreateEdit("", -2, -2, 921, 528, BitOR($ES_AUTOVSCROLL, $ES_WANTRETURN, $WS_VSCROLL, $ES_NOHIDESEL)) ;control ID ;-2 line up left, -2 line up top, +1 width, +1 bottom GUISetState(@SW_SHOW, $hFormTextEditor) ;display the GUI ;File Menu Local $idFileMenu = GUICtrlCreateMenu("&File") ;Create the file menu. This is the main menu and will have the sub-menus. Underline F when ALT is pressed. ;Main menu ;sub-menus Local $idFileMenu_Open = GUICtrlCreateMenuItem("&Open", $idFileMenu) ;Create the "Open" menu item. _GUICtrlEdit_SetText($cIDTextEdit, $data) ;display any file contents read in from like a command line filename Local $nMsg ;MAIN loop While 1 $nMsg = GUIGetMsg() ;Check what's happening in the GUI (Graphical User Interface) If $nMsg <> 0 Then ;we have a message so Switch $nMsg ;Check for GUI events ;Check File menu --- Case $idFileMenu_Open ;Open menu item clicked, or shortcut keys Ctrl+O = Open pressed Pause("Start: Case $idFileMenu_Open $file = '" & $file & "'") _Open("") ;let user pick it if $file = "" Pause("End: Case $idFileMenu_Open $file = '" & $file & "'") Case $GUI_EVENT_CLOSE Exit EndSwitch ;End running through GUI events. EndIf WEnd ;End main body loop ;File menu functions ======== Func _Open($file) ;_Open("") ;let user pick it v2cd Pause("In: Func _Open($file), $file = '" & $file & "'") If $file = "" Then ;let user pick the file $file = FileOpenDialog("Open",@WorkingDir,"text (*.txt)| all (*.*)") ;Start an open file dialog. Define text files (*.txt) as one filter, define all files (*.*) as a second filter. Pause("$file = '" & $file & "'") EndIf $data = FileRead($file) ;Read the data of the file _GUICtrlEdit_SetText($cIDTextEdit, $data) ;Set the data to be displayed $cIDFormTextEditorTitle = _GetShortFileName($file) ;set title with short filename WinSetTitle($hFormTextEditor, "", $cIDFormTextEditorTitle) Pause($file &@CRLF& "Read into editor.") EndFunc ;Func _Open() ;misc functions ======== Func _GetShortFileName($sfullfilename) Local $sDrive, $sDir, $sFileName, $sExtension ;for use by _PathSplit Local $aPathSplit = _PathSplit($sfullfilename, $sDrive, $sDir, $sFileName, $sExtension) Return($aPathSplit[3] & $aPathSplit[4]) ;return the short filename EndFunc ;Func _GetShortFileName($sfullfilename) Func Pause($text="") ;__scrolltext("Debug: Paused " & $text & @CRLF) MsgBox(262144, "DEBUG", "Paused: " & $text) EndFunc ;Func Pause($text="")
×
×
  • Create New...