-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
String.au3
50 lines (32 loc) · 1.01 KB
/
String.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.16.1
Author: Zvend
Script Function:
_String_Repeat($sString, $nRepeatCount) -> String
#ce ----------------------------------------------------------------------------
#include-once
;~ Repeats a string a specified number of times
Func _String_Repeat($sString, $nRepeatCount) ;-> String
$nRepeatCount = Int($nRepeatCount)
If $nRepeatCount = 0 Then
Return ""
EndIf
If StringLen($sString) < 1 Or $nRepeatCount < 0 Then
Return SetError(1, 0, "")
EndIf
Local $sResult = ""
If $nRepeatCount < 100 Then
For $i = 1 To $nRepeatCount
$sResult &= $sString
Next
Return $sResult
EndIf
While $nRepeatCount > 1
If BitAND($nRepeatCount, 1) Then
$sResult &= $sString
EndIf
$sString &= $sString
$nRepeatCount = BitShift($nRepeatCount, 1)
WEnd
Return $sString & $sResult
EndFunc