Jump to content
Sign in to follow this  
oxio

problem with function in a loop

Recommended Posts

oxio

hello,

im new with autoit so im just playing with it, normaly i do php for my work

but i dont know what i do here wrong.

#Include <Array.au3>

$Data = "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p"
$Array = StringSplit($Data,"|")

Func ShowMessage($char)
    MsgBox(4096,"",$char)
EndFunc

For $element In $Array
    HotKeySet($element, ShowMessage($element))
Next

Sleep(100000)

p.s sorry for my bad english its not what it should be

Share this post


Link to post
Share on other sites
Jos

hello,

im new with autoit so im just playing with it, normaly i do php for my work

but i dont know what i do here wrong.

#Include <Array.au3>

$Data = "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p"
$Array = StringSplit($Data,"|")

Func ShowMessage($char)
    MsgBox(4096,"",$char)
EndFunc

For $element In $Array
    HotKeySet($element, ShowMessage($element))
Next

Sleep(100000)

p.s sorry for my bad english its not what it should be

Second parameter of HotKeySet() requires a valid Func name defined in a string, not a Func.

HotKeySet($element, "ShowMessage")

You cannot use parameters in the defined Function when used in HotKeySet().

:)

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
oxio

thanks for your reply but whats a good solution to solve this script then?

Share this post


Link to post
Share on other sites
Jos

thanks for your reply but whats a good solution to solve this script then?

the @HotKeyPressed macro will contain the key pressed so you can use that in the "called" func.

#Include <Array.au3>
$Data = "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p"
$Array = StringSplit($Data, "|")
Func ShowMessage()
    MsgBox(4096, "", @HotKeyPressed)
EndFunc   ;==>ShowMessage
For $element In $Array
    HotKeySet($element, "ShowMessage")
Next
Sleep(100000)
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
PsaltyDS

the @HotKeyPressed macro will contain the key pressed so you can use that in the "called" func.

#Include <Array.au3>
$Data = "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p"
$Array = StringSplit($Data, "|")
Func ShowMessage()
    MsgBox(4096, "", @HotKeyPressed)
EndFunc   ;==>ShowMessage
For $element In $Array
    HotKeySet($element, "ShowMessage")
Next
Sleep(100000)oÝ÷ Ûú®¢×¢Ö^jVîµ+kx¦X­­ën®{r§¶)ôß +­¬´¶­Ê¢}ý·§¶Ú¶×¦¦ÛhjË(r&­y¡è´§²IëpØR Z+üæk)èµ·­æÞ²×è®ØZµªi'¶*'N¬jú"vÆ­µé©¶)ඬzØ^r§µ«ìºÚ"µÍÜ ÌÍÙHHHÈ ÌÍÐ^VÌBRÝÙ^]
    ÌÍÐ^VÉÌÍÙWK  ][ÝÔÚÝÓYÜØYÙI][ÝÊB^

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×