Jump to content

How to create a loop within AutoIT?


Recommended Posts

I would like to create a loop to call Main procedure a shown below, and would like to know on how loop and call between procedures work within AutoIT.

Does anyone have any suggestions?
Thanks in advance for any suggestions
======================================================================================

Sub Input_Loop()

For i = "a" to "z"

Main (i)

Next i

End Sub

Sub Main ( $Input_Char as String)

Local Const $sFilePath = "D:\Temp_" & $Input & ".txt"; which become "D:\Temp_k.txt" as return
Local $Input = $Input_Char

Local $hFileOpen = FileOpen("D:\Temp_" & $Input & ".txt", 2) ; which become "D:\Temp_k.txt" as return
FileWrite($hFileOpen, $Input & @CRLF)
FileClose($hFileOpen)

End Sub

 

Edited by oemript
Link to comment
Share on other sites

  • Moderators

oemript,

If you use Chr then you can get the loop to work:

For $i = 97 To 122
    _Main(Chr($i))
Next

Func _Main($sChar)
    ConsoleWrite($sChar & @CRLF)
EndFunc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

57 minutes ago, Melba23 said:

oemript,

If you use Chr then you can get the loop to work:

For $i = 97 To 122
    _Main(Chr($i))
Next

Func _Main($sChar)
    ConsoleWrite($sChar & @CRLF)
EndFunc

M23

For following codes, I need to add the $sChar into FilePath as well.

Local Const $sFilePath = "D:\Temp_" & $sChar & ".txt"; which become "D:\Temp_k.txt" as return

Local $hFileOpen = FileOpen("D:\Temp_" & $sChar & ".txt", 2) ; which become "D:\Temp_k.txt" as return

Do you have any suggestions on how to join the string together within AutoIT?
Thank you very much for any suggestions (^v^)

 

Edited by oemript
Link to comment
Share on other sites

  • Moderators

 

oemript,

Quote

Do you have any suggestions

Have you checked to see it what you have works? It looks to me as if it should:

For $i = 97 To 122
    _Main(Chr($i))
Next

Func _Main($sChar)
    ConsoleWrite("D:\Temp_" & $sChar & ".txt" & @CRLF)
EndFunc

M23

Edit: When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.

 

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Developers
1 hour ago, oemript said:

I would like to know on whether ErrorStdOut is Error or not.

I don't understand the question, please elaborate.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

All that parameter does is that AutoIt3 reports any messages to STDOUT/STDERR in stead of showing a MSGBOX, but I still don't understand what you are asking as you simply repeated what you typed before.... and I know I am slow but telling me twice the same things doesn't help much! :)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

oemript,

No, that is not the result of an error in your script - as Jos has pointed out above, it is a standard parameter to the wrapper function that SciTE uses when you run it so that any errors that you do have will appear in the SciTE console. Nothing to worry about!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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