Sign in to follow this  
Followers 0
sunlord

A question about GUICtrlSetOnEvent

10 posts in this topic

#1 ·  Posted (edited)

I'm trying to call a function that requires parameters ( I don't know if thats the right word) to be specified when a button is clicked. For example:

Func Blah($Something1, $Something2)
Do something
EndfuncoÝ÷ ٩ݧ!Úº ­®T´éĽéí¢{(æî¶Ú'Ëaz·*Z®ØºV«Á¬­¡Æ¥Øb±û§rبjëò¡«­¢+ÙÕ¥
ÑɱMÑ=¹Ù¹Ð ÀÌØíM½µÕÑѽ¸Ä°ÅÕ½Ðí    ±  ÀÌØíM½µÑ¡¥¹Ä°ÀÌØíM½µÑ¡¥¹È¤ÅÕ½Ðì

I get an error message.

Edited by sunlord

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

What's happening there is that it's calling the function

Blah($Something1, $Something2)()oÝ÷ Ú)ìµæ¡ú®¢Ðej®¢Ð0¢¹®§vh ÖÞjëh×6GuiCtrlSetOnEvent($Somebutton1, "Blah")

Func Blah()
Blah2($Something1, $Something2)
Endfunc

Func Blah2($Something1, $Something2)
;do something here
Endfunc

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@OP

You can't pass parameters on GUICtrlSetOnEvent(), look for EventHandler on the forum, to get an idea on how to do that.

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

There is no way to call a function with parameters using GuiCtrlSetOnEvent(), but you can use @GUI_CTRLID to identify which button was clicked and go from there.

Share this post


Link to post
Share on other sites

Could I do it like this?

Func $Blah2()
$some1 = Blah($Something1, $Something2)
EndfuncoÝ÷ Ù«­¢+ÙÕ¥
ÑɱMÑ=¹Ù¹Ð ÀÌØíM½µÕÑѽ¸Ä°ÅÕ½Ðí    ± ÈÅÕ½Ðì¤

Would that work?

Share this post


Link to post
Share on other sites

Could I do it like this?

Func $Blah2()
$some1 = Blah($Something1, $Something2)
EndfuncoÝ÷ Ù«­¢+ÙÕ¥
ÑɱMÑ=¹Ù¹Ð ÀÌØíM½µÕÑѽ¸Ä°ÅÕ½Ðí    ± ÈÅÕ½Ðì¤

Would that work?

If $something1 and $something2 are global variables then yes.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Don't think they're global variables. How do I make them global? Sorry, really noob question.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Don't think they're global variables. How do I make them global? Sorry, really noob question.

You would declare them with a "Global" in front of the variable name:

Global $something1 ;declares $something1 as a global variable

Here's an excerpt from the help file to help you with declaration:

The difference between Dim, Local and Global is the scope in which they are created:
Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!)
Global = Forces creation of the variable in the Global scope
Local = Forces creation of the variable in the Local/Function scope

You should use Local or Global, instead of Dim, to explicitly state which scope is desired for a variable/constant/array.

When using variables, the local scope is checked first and then the global scope second.
Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Could I do it like this?

Func $Blah2()
$some1 = Blah($Something1, $Something2)
EndfuncoÝ÷ Ù«­¢+ÙÕ¥
ÑɱMÑ=¹Ù¹Ð ÀÌØíM½µÕÑѽ¸Ä°ÅÕ½Ðí    ± ÈÅÕ½Ðì¤oÝ÷ Ùj.ÛajÜ(®Oêº^b¢é]vajÖî·rÂ¥w*.çÿ§¶Úz·¢±§(Ç©¶ð«Huë®&Þu¦è½æ®¶­sb6æ6ÇVFRfÇC´wV6öç7FçG2æS2fwC° ¤÷BgV÷C´wVöäWfVçDÖöFRgV÷C²ÂG'VR ¢b33c´uTÒuT7&VFRgV÷CµFW7BgV÷C²¤uT6WDöäWfVçBb33c´uTôUdTåEô4Äõ4RÂgV÷CµôWBgV÷C²¢b33c´'WGFöãÒuT7G&Ä7&VFT'WGFöâgV÷C´'WGFöãgV÷C²Â¤uT7G&Å6WDöäWfVçBÓÂgV÷Cµô'WGFöç2gV÷C²¢b33c´'WGFöã"ÒuT7G&Ä7&VFT'WGFöâgV÷C´'WGFöã"gV÷C²ÂÂC¤uT7G&Å6WDöäWfVçBÓÂgV÷Cµô'WGFöç2gV÷C²¢b33c´'WGFöã2ÒuT7G&Ä7&VFT'WGFöâgV÷C´'WGFöã2gV÷C²ÂÂs¤uT7G&Å6WDöäWfVçBÓÂgV÷Cµô'WGFöç2gV÷C²¢b33c´'WGFöãBÒuT7G&Ä7&VFT'WGFöâgV÷C´'WGFöãBgV÷C²Â¤uT7G&Å6WDöäWfVçBÓÂgV÷Cµô'WGFöç2gV÷C²¢b33c´'WGFöãRÒuT7G&Ä7&VFT'WGFöâgV÷C´'WGFöãRgV÷C²ÂÂ3¤uT7G&Å6WDöäWfVçBÓÂgV÷Cµô'WGFöç2gV÷C²¤uT6WE7FFR ¥vÆR 6ÆVWS¥tVæ@ ¤gVæ2ô'WGFöç2 b33c´7G&ÄBÒuTô7G&Ä@ 7vF6b33c´7G&Ä@ 66Rb33c´'WGFöã ×6t&÷cBÂgV÷CµFW7BgV÷C²ÂgV÷Cµ÷R6Æ6¶VBb33´'WGFöãb33²âgV÷C² 66Rb33c´'WGFöã  ×6t&÷cBÂgV÷CµFW7BgV÷C²ÂgV÷Cµ÷R6Æ6¶VBb33´'WGFöã"b33²âgV÷C² 66Rb33c´'WGFöã0 ×6t&÷cBÂgV÷CµFW7BgV÷C²ÂgV÷Cµ÷R6Æ6¶VBb33´'WGFöã2b33²âgV÷C² 66Rb33c´'WGFöã@ ×6t&÷cBÂgV÷CµFW7BgV÷C²ÂgV÷Cµ÷R6Æ6¶VBb33´'WGFöãBb33²âgV÷C² 66Rb33c´'WGFöãP ×6t&÷cBÂgV÷CµFW7BgV÷C²ÂgV÷Cµ÷R6Æ6¶VBb33´'WGFöãRb33²âgV÷C² VæE7vF6¤VæDgVæ2³ÓÒfwCµô'WGFöç0 ¤gVæ2ôWB W@¤VæDgVæ2³ÓÒfwCµôW

Share this post


Link to post
Share on other sites

I see! Thanks Big_daddy.

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