SaeidN

Using var in Function

3 posts in this topic

#1 ·  Posted (edited)

Hi,

I have the below function. I want to send different variable names to this function, and return the result back to where this func is called with different var names. Something like this when calling this func in another func maybe.

addComma($oldname, $newname)

So it sends the variable $oldname to this func and return it with $newname to where it's been called.

How do I do it?

Thanks

Func addComma()
Dim $t, $final

$Var = 123456789

$result = StringSplit($var, "")

For $x = $result[0] to 1 Step -1
    $t = $t +1
    If $t = 4 Then
        $final = "," & $final
        $t = 1
    EndIf
    $final =  $result[$x] & $final
Next
    MsgBox(0, "Results", $final)
EndFunc

 

Edited by SaeidN

Share this post


Link to post
Share on other sites



Just open the Helpfile on the Return command and look at the Byref and Return options also shown in the Example.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
13 minutes ago, Jos said:

Just open the Helpfile on the Return command and look at the Byref and Return options also shown in the Example.

Jos

Got it to work. Thank you

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