Jump to content
oemript

How to create a loop within AutoIT?

Recommended Posts

oemript

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

Share this post


Link to post
Share on other sites
Melba23

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

  • Thanks 1

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

Share this post


Link to post
Share on other sites
Melba23

 

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

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
oemript

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

For_Loop.png

Do you have any suggestions?
Thank you very much for any suggestions (^v^)

 

Edited by oemript

Share this post


Link to post
Share on other sites
Jos
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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
oemript

Please see following image, there is "ErrorStdOut", I would like to know on whether it is Error or not.

For_Loop.png

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Melba23

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


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
oemript

Thanks, to everyone very much for any suggestions (^v^)

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

×