Sign in to follow this  
Followers 0
Quinch

Retrieving a parameter as a string

6 posts in this topic

Is there a way to get a string form of a variable? Specifically...

Func Array_Insert($pid, ByRef $array)
    If IsInt($pid) = 0 Or $pid <= 0 Then 
        LogWrite("WARNING: PID "&$pid&" is not a natural number. Terminating script. Dumbass.")
        Exit
    ElseIf PID_Lookup($pid, $actors) = 0 Then
        ReDim $array[Ubound($array, 1)+1][Ubound($array, 2)]
        $array[Ubound($array, 1)-1][0] = $pid
        LogWrite("Item inserted in the "&$array&" array.")
    Else
        LogWrite("PID "&$pid&" already exists. Insertion aborted.")
    EndIf
EndFunc

In the eighth line, I want a successful insertion to be logged, with the name of the array the value's been added to - but as it is written, the $array variable just returns a blank, presumably due to the ByRef keyword. Any suggestions on what I should try?

Share this post


Link to post
Share on other sites



Well It looks to me like $Array is an array, and you aren't using $array[X][X] you are just writing $array


Regards,Josh

Share this post


Link to post
Share on other sites

Well It looks to me like $Array is an array, and you aren't using $array[X][X] you are just writing $array

Yeah, but I don't need the value inside the referenced $array.. I need the actual variable name in string form.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I don't know of any way to do that, or why you would wan't to do that. Add another parameter in your function.

EDIT: Or depending on how you are using your arrays, I would do something like:

Dim $array[x][x]
$array[0][0] = "name"

And then just use that 0,0 value as the name

Edited by JFee

Regards,Josh

Share this post


Link to post
Share on other sites

I don't know of any way to do that, or why you would wan't to do that. Add another parameter in your function

Well, I'd want to do that because I have a bunch of arrays which might use the same function, so having a log of what went on where and when is going to be useful. I could add another parameter, but it seems kinda messy.

Share this post


Link to post
Share on other sites

Read my EDIT in the above post. When you dim an array, give its [0][0] value the name you want to associate, or something along those lines


Regards,Josh

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