mcclane654 Posted November 5, 2013 Share Posted November 5, 2013 Global $messages = InputBox ("Title", "How many different messages?") Global $message[$messages] Local $creator While $creator < $messages $message[$creator] = InputBox ("Title", "what should message number $creator say?") $creator=$creator+1 WEnd the creator is going to display my number. but I can't get it to work as an variable since it's inside "". I have tried various methods without luck hope someone can help if this is possible. if you didn't understand please let me know and I'll try explaining it better Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 (edited) Welcome to AutoIt and the forum! Try this (untested): Global $messages = InputBox ("Title", "How many different messages?") If @error <> 0 Then Exit ; User cancelled $messages= Number($messages) If $messages <= 0 Then Exit ; Wrong input Global $message[$messages] For $creator = 0 to $messages - 1 ; - 1 because the index of an array starts at 0 $message[$creator] = InputBox ("Title", "What should message number " & $creator & " say?") If @error <> 0 Then Exit ; So the user can cancel the loop anytime Next Edited November 5, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 BTW: Please enclose AutoIt code in tags. Use the blue icon with an "A" in the editor. Enhances readability My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mcclane654 Posted November 5, 2013 Author Share Posted November 5, 2013 have more too my code than I posted " & $creator & " that worked my code is the same as yours with 2 exceptions. is it important to $messages= Number($messages) write number after =? and why do you write Next at the end? Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 Number is needed because InputBox returns a string and to remove all non-numeric characters. Next is needed to end the For statement. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
mcclane654 Posted November 5, 2013 Author Share Posted November 5, 2013 oh didn't use For xD is For better that while loop? inputbox dosen't return a string to me. at least it works fine. but if it removes all non numeric charaters I'll add it thx Link to comment Share on other sites More sharing options...
dreamzboy Posted November 5, 2013 Share Posted November 5, 2013 It's easier to manage an Array in a For loop than While Loop. You can code it to work with While loop but it's a little bit lengthier. Link to comment Share on other sites More sharing options...
mcclane654 Posted November 5, 2013 Author Share Posted November 5, 2013 Ok thx! I'll look into it. I used while loop since I got som experience from javascript and have to use my knowlegde from that but ofc learn new stuff as long as I understand it 100% Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 For better that while loop? If For is used there is no need to define the counter variable. That's implicitely done by AutoIt. So For and While are equivalent. For is for lazy people My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 inputbox dosen't return a string to me. at least it works fine. but if it removes all non numeric charaters I'll add it thx According to the docu InputBox returns a string. So if a user enters a number you get "3" (string) and not 3 (integer). Works fine until the user enters a character. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted November 5, 2013 Share Posted November 5, 2013 Ok thx! I'll look into it. I used while loop since I got som experience from javascript and have to use my knowlegde from that but ofc learn new stuff as long as I understand it 100% You can chose between While, For and Do / Until. If it solves your problem, it's perfect. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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