Examples
Code: Select all
; repeat three times, "#" means the head, "@`n" means the tail
print("ABC", 3, "@`n", "#")
; output: #ABCABCABC@
; Only repeat two times
print("ABC", 2)
; output: ABCABC
print("ABC", "###`n")
; output: ABC###
print("ABC", "`n", "!!!!")
; output: !!!!ABC
print(2 + 1, 5)
; output: 33333
Code: Select all
print(anyvar, params*)
{
outputStr := "" ; output strings
times := 1 ; The number of "str" to repeat in outputStr
tailStr := "" ; Appeared in the end of outputStr
headStr := "" ; The begining of outputStr
for index, var in params
{
if (index >= 4), return ; Ignore the remaining paraments
vType := _type(var)
if (vType = "Integer") ; suppose all inputs are vaild, "Integer" will appear no more than once
{
times := var
}
else if (vType = "String")
{
if (tailStr = "") ; tail comes first
{
tailStr := var
}
else
{
headStr := var
}
}
}
outputStr := headStr
Loop % times
{
outputStr .= anyvar
}
outputStr .= tailStr
; write to ouput panel of SCITE
FileAppend , % outputStr, *
return outputStr
}
_type(n)
{
; V2 supports type function
if (SubStr(A_AhkVersion, 1, 1) = 2)
{
return type(n)
}
; V1
ret := (RegExMatch(n, "^[+]?[0-9]+$") > 0) or (RegExMatch(n, "i)^0x[0-9a-f]+$") > 0) ; An integer
if (ret)
{
return "Integer"
}
return "String"
}