MadAndroid Posted July 31, 2015 Posted July 31, 2015 Hi,This code intented to do all the combinations of 2 digit numbers but has to be stoped anytime and must return at the point it stopped before. I thought of saving the vector`s index and passed it again when the code restarted. I was succesful in writing the vector`s index in a FileOpne.txt archive but did not manage to read it and pass the index to the $aArrayComb vector. Does anybody could help me with that ?expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.12.0 #ce ---------------------------------------------------------------------------- #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include <Misc.au3> $aArrayComb = '0123456789' $aArrayComb = StringSplit($aArrayComb, "") Local Const $sFilePath = "C:\FileOpen.txt" ; Abrir O Arquivo Local $hFileOpen = FileOpen($sFilePath, $FO_READ + $FO_OVERWRITE) If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "There is not a previous point break.") EndIf HotKeySet("{ESC}", "Terminate") $chave = "" For $1 = 1 To $aArrayComb[0] For $2 = 1 To $aArrayComb[0] For $3 = 1 To $aArrayComb[0] $chave &= "Combination : " & $aArrayComb[$1] & $aArrayComb[$2] & $aArrayComb[$3] & " Position : " & $1 & $2 & $3 & @CRLF Consolewrite($chave & @crlf) Next Next Next Func Terminate() $pos = $1 & $2 & $3 FileWrite("C:\FileOpen.txt", $pos) Exit EndFunc
computergroove Posted July 31, 2015 Posted July 31, 2015 Add a paused function:Global $Paused HotKeySet("{PAUSE}", "TogglePause") $Paused = $Paused ;your code here Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
Moderators Melba23 Posted July 31, 2015 Moderators Posted July 31, 2015 MadAndroid,all the combinations of 2 digit numbersApart from the fact that the script produces all the combinations of 3-digit numbers, why do you need to do this?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
MadAndroid Posted July 31, 2015 Author Posted July 31, 2015 computergroove,Thankyou but I didn`t get the point. My problem is to make the code returns to the point it was early terminated. I put a function called by the "ESC" key so I could stop it anytime but I wish I could restart it from there....
computergroove Posted July 31, 2015 Posted July 31, 2015 You need to answer melba before i will help you further. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
MadAndroid Posted July 31, 2015 Author Posted July 31, 2015 M23, You`re right...I changed the code before posted from 2 to 3 number combinations. Answering your question this is an academic exercise of algoritmics but I am a beginner studing Autoit by myself.
Moderators Melba23 Posted July 31, 2015 Moderators Posted July 31, 2015 MadAndroid,an academic exercise of algoritmicsThen why do you wish to save the results in a file with the specific "Combination" & "Position" headings? To me that seems a strange thing for a simple algorithm test to do.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
MadAndroid Posted July 31, 2015 Author Posted July 31, 2015 M23,I don`t know how to manipulate archives in Autoit. The examples "Notepad1 or Notepad2 that come with the software`s instalation shows how to write I that was as far as I could do.I have the algoritm in "natural language" to implement and chose to do in Autoit. So, after have read the content of the archive c:\FileOpen.txt I need to read the first digit o the number and pass it to the vector of the first "for". In my code I opened the archive to read its content with this lines:Local $hFileOpen = FileOpen($sFilePath, $FO_READ + $FO_OVERWRITE)If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "There is not a previous point break.")EndIfWhat I expected is that the MsgBox opens to me as the archive didn`t exists the first time the code runned but it didn`t worked and I don`t know why. So I decided to ask for help in this point at least.
MadAndroid Posted July 31, 2015 Author Posted July 31, 2015 I also tried to use this lines :Local $sFileRead = FileRead($hFileOpen) If $hFileOpen = 1 Then MsgBox($MB_SYSTEMMODAL, "String anterior ", $sFileRead) EndIfbut the MsgBox returns empty and it not empty because I opened with Notepad and the number was there...
MadAndroid Posted July 31, 2015 Author Posted July 31, 2015 Hi,I`ve just solved the problem to read the file. Now I need help just to read the first, second and third digit of the string I`ve read.I apologise some help.
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