User9999 Posted January 16, 2011 Share Posted January 16, 2011 Hello guys, I have some doubts I would like to know how to change an STRING in a loop like : 1st time a1 2nd time a2 3rd time a3 4th time a4 something like that. And also concatenate the string in a text that I am sending by using Send() method. Thanks Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted January 16, 2011 Share Posted January 16, 2011 One way to do it: For $iX = 1 To 4 Send("a" & $iX) Next .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Varian Posted January 16, 2011 Share Posted January 16, 2011 Not sure if this is what you are looking forLocal $CurrentIteration, $String For $i = 1 to 10 $CurrentIteration = 'a' & $i $String &= $CurrentIteration & @LF MsgBox(262208, 'Current String = ' & $CurrentIteration, 'String = ' & $String) Next Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 16, 2011 Share Posted January 16, 2011 (edited) For $i = 1 to 4 ConsoleWrite("The variable is A" & $i & @LF) NextThe & character is used to concatenate stuff. See here, http://www.autoitscript.com/autoit3/docs/intro/lang_operators.htm Edited January 16, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Malkey Posted January 17, 2011 Share Posted January 17, 2011 (edited) Allowing for "st, "nd", and "rd". ; Output :- ;1st time a1 ;2nd time a2 ;3rd time a3 ;4th time a4 ;.... Local $sStr, $sNumType For $i = 1 To 24 Select Case Mod($i, 10) = 1 $sNumType = "st" Case Mod($i, 10) = 2 $sNumType = "nd" Case Mod($i, 10) = 3 $sNumType = "rd" Case Else $sNumType = "th" EndSelect If Mod($i, 100) = 11 Or Mod($i, 100) = 12 Or Mod($i, 100) = 13 Then $sNumType = "th" $sStr &= $i & $sNumType & " time a" & $i & "{ENTER}" ; or @LF Next Run("notepad.exe") WinWaitActive("Untitled - Notepad") WinMove("Untitled - Notepad", "", (@DesktopWidth - 300) / 2, (@DesktopHeight - 650) / 2, 300, 650) Send($sStr) Similar to above, but in function form. expandcollapse popup; Output :- ;1st time a1 ;2nd time a2 ;3rd time a3 ;4th time a4 ;.... ; Modified from http://www.autoitscript.com/forum/topic/...-strings/page__view__findpost_ ; http://www.autoitscript.com/forum/topic/124334-manipulating-strings/page__view__findpost__p__863571 Local $sStr For $i = 1 To 24 $sStr &= $i & _OrdinalAbbrev($i) & " time a" & $i & "{ENTER}" ; or @LF Next Run("notepad.exe") WinWaitActive("Untitled - Notepad") WinMove("Untitled - Notepad", "", (@DesktopWidth - 300) / 2, (@DesktopHeight - 650) / 2, 300, 650) Send($sStr) ; Ordinal abbreviations are actually hybrid contractions of a numeral and a word. 1st is ; "1" + "st" from "first". Similarly, we use "nd" for "second" and "rd" for "third". ; From http://en.wikipedia.org/wiki/English_numerals ; Returns: Either "st", "nd", "rd", or "th" ; Func _OrdinalAbbrev($iNum) Local $sOrdAbbr Select Case IsNumber($iNum) = 0 ; If not a number Return "" Case Mod($iNum, 100) = 11 Or Mod($iNum, 100) = 12 Or Mod($iNum, 100) = 13 Return "th" Case Mod($iNum, 10) = 1 Return "st" Case Mod($iNum, 10) = 2 Return "nd" Case Mod($iNum, 10) = 3 Return "rd" Case Else Return "th" EndSelect EndFunc ;==>_OrdinalAbbrev Edit: Updated function. Edited January 18, 2011 by Malkey 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