Jump to content
MadAndroid

Open a file for reading contents

Recommended Posts

MadAndroid

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 ?

#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

 

Share this post


Link to post
Share on other sites
computergroove

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

Share this post


Link to post
Share on other sites
Melba23

MadAndroid,

all the combinations of 2 digit numbers

Apart 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
MadAndroid

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

Share this post


Link to post
Share on other sites
computergroove

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

Share this post


Link to post
Share on other sites
MadAndroid

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.

Share this post


Link to post
Share on other sites
Melba23

MadAndroid,

an academic exercise of algoritmics

Then 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
MadAndroid

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.")
EndIf

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

 

Share this post


Link to post
Share on other sites
MadAndroid

I also tried to use this lines :

Local $sFileRead = FileRead($hFileOpen)

If $hFileOpen = 1 Then
   MsgBox($MB_SYSTEMMODAL, "String anterior ", $sFileRead)
EndIf

but the MsgBox returns empty and it not empty because I opened with Notepad and the number was there...

Share this post


Link to post
Share on other sites
MadAndroid

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.

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

  • Similar Content

    • smud
      By smud
      Currently, I'm working on a program that will display Dialog boxes with either Yes or No.
      For each dialog, I reward the user with X amount of Credits.
      I'm hoping to output the amount of credits to a cell in a column (there will be 20 different columns).
      It will only post to a row that is equal to today's date (first column). If no row exists yet with the current date, it will start a new row.
      Any suggestions?
      Thank you
    • nacerbaaziz
      By nacerbaaziz
      hi dears
      am using an ini files as a History
      Sometimes the file size is be larger to 5 MB
      AutoIt does not recognize the full content of the file
      When I did a search to find out why, I discovered that INI files could not be read if they size larger than 64 KB.
      for that I preferred to ask here if is there any way to bypass this obstacle.
      The contents of the file are  as follows
      [filesList]
      c:\...\...\f1.mp3=00:15:20
      c:\...\...\f2.mp3=00:10:20
      c:\...\...\f3.wav=00:59:20
      ....... Etc
      This is the section for reading the file (adapted from my main script)

      case $continue     Local $aArray = IniReadSection($WaitingListFile, StringEncrypt(true, "filesList", $MyPassword))     If Not @error Then Opt("GUICloseOnESC", 1) _GUICtrlListView_DeleteAllItems($scList)         For $i = 1 To $aArray[0][0] $path = path_list(StringEncrypt(false, $aArray[$i][0], $MyPassWord), 1) if FileExists(StringEncrypt(false, $aArray[$i][0], $MyPassWord)) then GUICtrlCreateListViewItem(_GetFileName(FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord))) & Opt("GUIDataSeparatorChar") & " : " & Opt("GUIDataSeparatorChar") & FileGetLongName(StringEncrypt(false, $aArray[$i][0], $MyPassWord)), $scList) else $path = $path endIf         Next GUISetState(@sw_disable, $hGUI) GUISetState(@sw_show, $hGUI2) GUICtrlSetState($SClist, $GUI_FOCUS) else if $accessibilitymode = 1 then speak(str("listEmpty")) endIf endIf
      Is there any way to solve this problem, please?
      am waiting your answers...
      Greetings to All
    • caramen
      By caramen
      Hey.  
       
      I requested help about how to get a value from a text in a variable. 
      Now i know how to do that. But i learned with the command FileRead. Now i whould like to know how to replace the command :
      FileRead('Dossier.txt') The purpose is to read a webpage text. To find some value inside. 
       
      Btw i tryed to play with WindowsInfo.au3 but i dont got much thing.  
    • dadalt95
      By dadalt95
      Hi!
      I want to get the signal in this website:
      https://binary-signal.com/pt/chart/eurusd
      I have tried using _IEBodyReadText  and some _StringBetween. What happens is that the text are being update every tick and _IEBodyReadText doesn't.
      To perform the update I used  _IEAction($oIE, "refresh") but it's not good because the website block me after some time due too many requests..
      Is there any other way to get this text every tick?
      PS: The text I want to get is WAIT, CALL or PUT.
       
      Here is the code:
      global $oIE = _IECreate ('https://binary-signal.com/pt/chart/eurusd', 0, 1 , 1 , 0) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') ;MsgBox ( 0, "asf", $result[0]) $espera=StringInStr($result[0], "WAIT") $compra=StringInStr($result[0], "CALL") $venda=StringInStr($result[0], "PUT") ;MsgBox($MB_SYSTEMMODAL, "", $espera) $n=0 $c=0 Captar() Func Captar() ;_IENavigate($oIE, "https://binary-signal.com/pt/chart/eurusd") ;MsgBox($MB_SYSTEMMODAL, "", $n) Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') If (Not $compra=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "COMPRE") $n=1 $c=$c+1 ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=0 Then MsgBox($MB_SYSTEMMODAL, "", "VENDA") $c=$c+1 $n=1 ;_IEAction($oIE, "refresh") ;MsgBox($MB_SYSTEMMODAL, "", $n) Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() ElseIf (Not $venda=0) And $n=1 Then ;MsgBox($MB_SYSTEMMODAL, "", "Esperando próxima rodada") $n=1 ;MsgBox($MB_SYSTEMMODAL, "", $n) ;_IEAction($oIE, "refresh") Sleep(60000) Captar() Else ;MsgBox("", "", "ESPERE") $n=0 Sleep(1000) ;_IEAction($oIE, "refresh") Local $sText = _IEBodyReadText($oIE) $result = _StringBetween ( $sText , 'PUTEUR/USD on Binary-signal.com', 'sinal está PRONTA') Captar() EndIf EndFunc  
    • Trisha
      By Trisha
      Hello,
      I Have clicked on save as option to save a file, while doing that I need to rename a file appending with sysdate. I have searched in google find the below one line of code:
      FileMove("C:\somefile.txt", "C:\somefile1.txt"), When I am trying to append with sysdate. It is not happening. Please help me out  with the small issue.
×