Jump to content
IAMK

Using a string literally for function parameters

Recommended Posts

IAMK

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.

Share this post


Link to post
Share on other sites
iamtheky
$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)

 


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

Share this post


Link to post
Share on other sites
IAMK

@iamtheky

ToolTip(execute($stuff2), 0, 0)    ;This puts it at 0, 0, but if I want the position to be defined in the string, how would I do that?

Share this post


Link to post
Share on other sites
iamtheky

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)

 


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

Share this post


Link to post
Share on other sites
IAMK

@iamtheky

That's messier than I would have liked, but it works.

Thank you for your quick response.

Share this post


Link to post
Share on other sites
iamtheky

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?


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

Share this post


Link to post
Share on other sites
kylomas

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

Share this post


Link to post
Share on other sites
Danyfirex

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

Share this post


Link to post
Share on other sites
Atoxis

Howdy, I just made a post about a problem i'm having and I think this might help me a tad.

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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.