Jump to content

Using a string literally for function parameters


IAMK
 Share

Recommended Posts

Hello,

 

I am trying to use a string variable like a hash definition.

From what I read, hash definitions cannot be used for this, and I am unable to do it with strings.

 

Example of what I want:

$stuff1 = "Words", 0, 0    ;Literally this.

$stuff2 = """Words"", 0, 0"    ;This outputs the string exactly as it is seen in $stuff1

ToolTip($stuff2)    ;I want this to run ToolTip("Words", 0, 0)

 

How can I achieve this result?

 

Thank you in advance.

Link to comment
Share on other sites

$stuff2 = """Words"", 0, 0"    ;This outputs the string exactly as it is seen in $stuff1

Tooltip( execute($stuff2) )   ;I want this to run ToolTip("Words", 0, 0)

sleep (10000)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

because im retarded, i totally meant to use eval and that would have resulted in at best similar results, at worst all of those items in the first parameter. going to probably have to split that into the multiple parameters rather than passing a string that is interpreted as three distinct parameters

$Stuff2 = 'Words, 0, 0'    ;This outputs the string exactly as it is seen in $stuff1

Tooltip( stringsplit($stuff2 , "," , 2)[0] , stringsplit($stuff2, "," , 2)[1] , stringsplit($stuff2, "," , 2)[2]  )   ;I want this to run ToolTip("Words", 0, 0)

sleep (10000)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

If you could store it as an array rather than a string you wouldnt need the split.  Because ultimately in this effort you are passing a string, to a function which accepts a string as its first parameter, how else would you expect it to know you want this particular string split if the only commas you can pass will be within the string you are passing?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

IAMK, 

You could use a wrapper function like so...

Local $parm1 = 'words', $parm2 = 100, $parm3 = 0

_myToolTip($parm1, $parm2, $parm3)

Func _myToolTip($p1, $p2, $p3)

    ToolTip($p1, $p2, $p3)
    Sleep(2000)

EndFunc   ;==>_myToolTip

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Hello Just for fun...

 

Local $stuff1 = '"Words", 0, 0'
Local $stuff2 = '"Words", 300, 300'
Local $stuff3 = '"Words", 300, 300, "SomeTitle" ,1,1'

_ToolTip($stuff1)
Sleep(3000)
_ToolTip($stuff2)
Sleep(3000)
_ToolTip($stuff3)
Sleep(3000)
Func _ToolTip($sParam)
    Local $aParam[] = ["", Default, Default, "", 0, Default]
    Local $aSplit = StringSplit($sParam, ",")
    For $i = 1 To $aSplit[0]
        $aParam[$i - 1] = $aSplit[$i]
    Next
    ToolTip($aParam[0], $aParam[1], $aParam[2], $aParam[3], $aParam[4], $aParam[5])
EndFunc   ;==>_ToolTip

Saludos

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...