BlackFlag Posted February 20, 2015 Share Posted February 20, 2015 My very simple code. expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <File.au3> #Include<Array.au3> #Include<Date.au3> $Work = GUICreate("Work Journal", 623, 330, 192, 114) $Edit1 = GUICtrlCreateEdit("", 8, 16, 505, 265) ;GUICtrlSetData(-1, "Edit1") $Save = GUICtrlCreateButton("Save", 8, 288, 73, 25) $Label1 = GUICtrlCreateLabel("Tags", 536, 24, 43, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Vessel = GUICtrlCreateRadio("Vessel Issue", 528, 56, 81, 25) $Bad = GUICtrlCreateRadio("Bad News", 528, 88, 89, 25) $WhattheHell = GUICtrlCreateRadio("Dev Issue", 528, 120, 89, 25) $Watch = GUICtrlCreateRadio("Watching", 528, 152, 89, 25) GUISetState(@SW_SHOW) $TheJournal=fileopen("C:\Documents and Settings\Daniel\My Documents\Work Journal\WorkNotes.txt",1) While 1 Switch GUIGetMsg() Case $Save $Watching=GUICtrlRead($Watch) $BadNews=GUICtrlRead($Bad) $Boat=GUICtrlRead($Vessel) $What=GUICtrlRead($WhattheHell) $TextInfo=GUICtrlRead($Edit1) $Today =_NowDate() Filewrite($TheJournal,"---------------------------------"&@CRLF) FileWrite ($TheJournal,$Today&@CRLF&@CRLF) FileWrite($TheJournal,$TextInfo&@CRLF) Exit EndSwitch WEnd When I run this it usually works fine. However, when I click on Dev Issue the program, when ran in SciTE anyway, does an immediate exit. There are no messages and Exit code= 0. The rest of the radio button work fine. A) Does this crash for anyone else? Do I have an error I am just missing? C) If not B, anyone have a clue what is going on here? Link to comment Share on other sites More sharing options...
Danyfirex Posted February 20, 2015 Share Posted February 20, 2015 Don't forget close file handle. FileClose($TheJournal) maybe for that the app is not Flushing the data. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
SadBunny Posted February 21, 2015 Share Posted February 21, 2015 (edited) Works fine for me. In that it doesn't crash on any click anywhere, and that it writes to the defined textfile. Which Windows version are you using, is there any other code in your script, any directives used on top? Edited February 21, 2015 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
BlackFlag Posted February 21, 2015 Author Share Posted February 21, 2015 Xp is what it is being tested on. This is for a couple of my users, one of which has to use xp due to legacy issues. I will try it on one of our Win 7 machines on Monday. I should have thought of that myself . At the moment, that is the entire script. I just started the project. Link to comment Share on other sites More sharing options...
mikell Posted February 21, 2015 Share Posted February 21, 2015 Works well on my XP with no crash - and I can't see a reason why it sould crash Link to comment Share on other sites More sharing options...
kylomas Posted February 22, 2015 Share Posted February 22, 2015 BlackFlag, I cannot get it to fail either. After looking at your code I made some changes... 1 - got rid of intermediate variables 2 - added header formatting from radio button text (the only reason I could see for the vars you were setting) 3 - added a limit to edit control (100000 characters) 4 - changed "exit" to "exitloop" 5 - added a display of the file 6 - changed the filename See the comments in code.... expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <File.au3> #include <Array.au3> #include <Date.au3> $Work = GUICreate("Work Journal", 623, 330, 192, 114) $Edit1 = GUICtrlCreateEdit("", 8, 16, 505, 265) GUICtrlSetLimit(-1, 100000) ; set limit to 100000 characters $Save = GUICtrlCreateButton("Save", 8, 288, 73, 25) $Label1 = GUICtrlCreateLabel("Tags", 536, 24, 43, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Vessel = GUICtrlCreateRadio("Vessel Issue", 528, 56, 81, 25) $Bad = GUICtrlCreateRadio("Bad News", 528, 88, 89, 25) $WhattheHell = GUICtrlCreateRadio("Dev Issue", 528, 120, 89, 25) $Watch = GUICtrlCreateRadio("Watching", 528, 152, 89, 25) GUISetState(@SW_SHOW) $TheJournal = FileOpen(@ScriptDir & "\WorkNotes.txt", 1) Local $hdr, $msg ; <---- added to get text of radio button and format output header While 1 ; set $msg to control actioned so that it can be used in a GuiCtrlRead later $msg = GUIGetMsg() Switch $msg ; sets text of radio button clicked Case $Vessel, $Bad, $WhattheHell, $Watch $hdr = GUICtrlRead($msg, 1) ; The ", 1" gets the text of the control (advanced mode) Case $Save ;$TextInfo = GUICtrlRead($Edit1) ; no need for an intermediate var ;$Today = _NowDate() ; no need for an intermediate var FileWrite($TheJournal, "--------------------------------- " & $hdr & " -------------------------------" & @CRLF) FileWrite($TheJournal, _NowDate() & @CRLF & @CRLF) FileWrite($TheJournal, GUICtrlRead($Edit1) & @CRLF) ExitLoop ; exit loop will also exit the script if nothing follows the loop / for testing I want to see the file EndSwitch WEnd ShellExecute(@ScriptDir & "\WorkNotes.txt") ; display the file using the default windows handler for ".txt" kylomas Tripredacus 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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