Sign in to follow this  
Followers 0
gruntydatsun

Function that creates string with X number of a char

4 posts in this topic

Hello,

Does anyone know the function that creates a string with X number of characters...

like: MakeString(".",10)

for a string with 10 .'s

Share this post


Link to post
Share on other sites



Not quite what you asked for - but a function I use for something similar is:

$string = "EXTRA:"

$string = $string & _Padding($string,".")

msgbox(0,"Test",$string)

Func _Padding($strPad, $padchar)

Local $x, $msg

For $x = 1 to 14

$msg=$msg & $padchar

if StringLen($strPad & $msg) >= 14 Then ExitLoop

Next

Return $msg

EndFunc

$string will = input string + the padding character up to 14 characters in total

Cheers,

Jim Bo

Hello,

Does anyone know the function that creates a string with X number of characters...

like: MakeString(".",10)

for a string with 10 .'s

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello,

Does anyone know the function that creates a string with X number of characters...

like: MakeString(".",10)

for a string with 10 .'s

I fail to see the complexity of what you are asking really. If you've ever worked with functions or loops, it would have taken you less time to write the function yourself then it did to start the thread.
MsgBox(64, "Info", _MakeString(".", 10))

Func _MakeString($sChar, $nCount)
    Local $sHold
    For $iCC = 1 To $nCount
        $sHold &= $sChar
    Next
    Return $sHold
EndFunc

Edit:

I thought I remembered a function to do this already in existence....

_StringRepeat

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Nice. Thanks for that Smoken. Your edit was the answer to the question minus the judgement....

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
Sign in to follow this  
Followers 0