[WT-support] LUA-Script and Arguments

Laurent HAAS - F6FVY f6fvy at free.fr
Tue Dec 1 15:57:41 CET 2009


Hi Franta

Franta Bendl a écrit :

> But is there reason, why the Script-Manager denys the usage of one script more 
> times (for different keys)? I believe it is the trick of the usage of an 
> argument to use the same script for the different functions even controlled 
> by the argument. But I can't find a way how to realize it in Wintest/Script 
> manager.

Currently the Script Manager do not allow the same script to be called 
with different keys.

But you can easily circumvent this limitation the following way (just an 
useless example, but you get the picture) :

script f8.wts (key F8, argument 8)
==================================

wtApp:CallScript("generic");
return -1

script f9.wts (key F9, argument 9)
==================================

wtApp:CallScript("generic");
return -1

script f10.wts (key F10, argument 10)
=====================================

wtApp:CallScript("generic");
return -1

script generic.wts (no associated key, no argument)
===================================================

wtApp:AlertBox("Key F" .. wtArgument .. " was pressed !");

Another way is to use functions (a bit faster - if you need speed ;-) ) :

script f8.wts (key F8, argument 8)
==================================

if (fnGeneric == nil) then
   wtApp:CallScript("generic"); -- Define the function once only
end;

wtApp:AlertBox(fnGeneric());
return -1

script f9.wts (key F9, argument 9)
==================================

if (fnGeneric == nil) then
   wtApp:CallScript("generic");
end;

wtApp:AlertBox(fnGeneric());
return -1

script f10.wts (key F10, argument 10)
=====================================

if (fnGeneric == nil) then
   wtApp:CallScript("generic");
end;

wtApp:AlertBox(fnGeneric());
return -1

script generic.wts (no associated key, no argument)
===================================================

function fnGeneric()
   return "Key F" .. wtArgument .. " was pressed !";
end;


73

Larry - F6FVY


More information about the Support mailing list