Jump to content

How do i execute functions in a variable?


Mcky
 Share

Recommended Posts

Example:

$data='MsgBox(0,"Test","Test message")'

How do i execute the function in the variable $data?

My website: (Lots of AutoIt compiled programs+GameMaker games)http://mcky.sitesled.comMy AutoIt projects:Mcky's CalEntry - Calendar schedulingMcky's Web Extractor - Web page links extractorMcky's Appkey- Powerful Hotkey-listing tool[quote]I wish I was never born. I am just a lonely soul in this world... :([/quote]
Link to comment
Share on other sites

Notice the single quote around the MsgBox function...

$data is set to the string 'MsgBox(0,"Test","Test message")'

I just want to know how to execute $data in order to display the Message box.

My website: (Lots of AutoIt compiled programs+GameMaker games)http://mcky.sitesled.comMy AutoIt projects:Mcky's CalEntry - Calendar schedulingMcky's Web Extractor - Web page links extractorMcky's Appkey- Powerful Hotkey-listing tool[quote]I wish I was never born. I am just a lonely soul in this world... :([/quote]
Link to comment
Share on other sites

Notice the single quote around the MsgBox function...

$data is set to the string 'MsgBox(0,"Test","Test message")'

I just want to know how to execute $data in order to display the Message box.

<{POST_SNAPBACK}>

Ah, you want to put a function in a varaible to save typing?

I only believe that you can put the results of the function into a variable, not the function itself.

Besides, doing something like that would only obfuscate and muddy the code.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

When u want to do that kind of things use FUNCTIONS :lmao:

Andre

<{POST_SNAPBACK}>

Well, yeah, there's that too. o:)

Static:

Func MB()
  MsgBox(0,"test","test text")
EndFunc

Or

Dynamic:

Func MB($i=0,$sTitle="test",$sText="test text")
   $return = MsgBox($i,$sTitle,$sText)
   Return $return
EndFunc

But, if I want a debug message box, I just use SciTE and hit Ctrl+Alt+D

Edit: Added a return value to the MB function. :) Yeah, forgot about the yes/no/cancel stuff.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Notice the single quote around the MsgBox function...

$data is set to the string 'MsgBox(0,"Test","Test message")'

I just want to know how to execute $data in order to display the Message box.

You could try this:

....
if something then
SpecialMsg("Hello world")
else
SpecialMsg("Goodbye world")
endif
Func SpecialMsg($msg1)
Msgbox(0,"Title",$msg1)
exit
Endfunc
[u][font="Arial"]Pete[/font][/u]
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...