Jump to content

Retrieving a parameter as a string


 Share

Recommended Posts

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?

Link to comment
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.
Link to comment
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.

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

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...