PDA

View Full Version : DUI, Action list returns and the file functions.



danward79
October 3rd, 2005, 12:29 PM
Hi,

I am in the process of making actions for the file functions I made using the win namespace stuff. see below link for details

http://www.promixis.com/phpBB2/viewtopic.php?t=12196&postdays=0&postorder=asc&start=0

I am a little stuck at the moment thou, as I am unsure how to link a function return to a linked action.

I have found the link button. but how do I link the action I select in that to the return of the function?

danward79
October 3rd, 2005, 12:43 PM
and what is the difference between and svalue and an ivalue?

:-?

Promixis
October 3rd, 2005, 12:44 PM
Dan, each action has a unique number that you assign using the designer and then use in the script

here is some code from my HAI plugin



--[[

1.a bypass zone

sValue2= code

--]]

treescript.Action[3]={

OnAction=function ( Action, Event )
local zone = tonumber (Action.sValue3) + 1
local code = tonumber (Action.sValue2)
HAI:BypassZone (code,zone)
end,


OnShow=function ( Index, Action, Controls)

local l = ''
dui.Forms[Index].List = {}
for k,v in ipairs (HAI.Zones) do
if k <= HAI.Model.Zones then
l = l .. v.Name ..'\n'
dui.Forms&#91;Index&#93;.List &#91;k&#93; = v
end
end
Controls.List.Strings = l
Controls.List.ItemIndex = tonumber &#40;Action.sValue3&#41;
if Controls.List.ItemIndex < 0 then
Controls.List.ItemIndex = 0
end
BuildCodeList &#40;Index,Controls,Action&#41;

Controls.Model.Caption = HAI&#58;GetModelInfo &#40;&#41;
end,


OnApply=function &#40; Index, Action, Controls&#41;

Action.sValue3 = Controls.List.ItemIndex
if dui.Forms&#91;Index&#93;.Codes then
Action.sValue2 = dui.Forms&#91;Index&#93;.Codes &#91;Controls.Codes.ItemIndex+1&#93;
end

end,



OnDefaults=function &#40;Index, Action&#41;

Action.sValue3=1 -- zones
Action.sValue2=254 -- code

end,


OnEvent= function &#40;Index, Action, Controls, Control, ID1, ID2&#41;

end,


OnClose =function &#40;Index, Action, Controls&#41;
end,

&#125;

danward79
October 3rd, 2005, 12:49 PM
For the action number at the moment, I am using 900, 901, etc, etc.

Promixis
October 3rd, 2005, 12:58 PM
ok, make sure you list them in the sticky above.

danward79
October 3rd, 2005, 01:15 PM
yep, no problem. I was going to finalise all that shortly.


Should I be using sValue for the link button?

I an tring to use the following to link to an event in girder.


local file = Action.sValue1

if File&#58;DoesFileExist &#40;file&#41; then

gir.TriggerEvent&#40;Action.sValue2, 18&#41;
else

gir.TriggerEvent&#40;Action.sValue3, 18&#41;
end

But it is not causing it to trigger an event.

This is for the "DoesFileExist" action, sValue1 = the file, sValue2 = girder event if true, sValue3 = girder event if false

anyideas?

danward79
October 4th, 2005, 10:11 AM
I still can't figure this out. What am I do that is stupid! :oops:

Ron
October 5th, 2005, 06:56 AM
Best thing to do is have the links be set automatically nto one of the lValue (that is Lvalue) fields. You can do it from Lua and then you'll also have to store them in the lValue fields so there is not real advantage to using Lua on this one.

danward79
October 5th, 2005, 07:49 AM
I don't think I get you. So you reckon I should use Lvalues?

danward79
October 5th, 2005, 07:50 AM
Is there an example anywhere? I can't seem to find one.

Ron
October 5th, 2005, 07:50 AM
If you want to store any Link-Button values you must use Lvalues yes.

Ron
October 5th, 2005, 07:53 AM
open dynamicui.xml in the designer and go to Flow Control->Window is Foreground?

You'll see the Link button linked to lValue1 and lValue2. (Lvalue#)

danward79
October 5th, 2005, 10:26 AM
Ok, Thanks for the pointer, but it is the lua script side I am stuck with.

should this work in principle?


OnAction=function &#40; Action, Event &#41;
local file = Action.sValue1

if File&#58;DoesFileExist &#40;file&#41; then
print &#40;"True",Action.lValue1&#41;
gir.TriggerEvent&#40;Action.sValue1, 18&#41;
else
print &#40;"False",Action.lValue2&#41;
gir.TriggerEvent&#40;Action.lValue2, 18&#41;
end
return
end,

I chucked in the print statements just to see, and I don't see a lvalue appart from 0

Ron
October 5th, 2005, 10:33 AM
TriggerEvent is not the rigth function for that, in fact I am not sure it is smart to directly trigger a node from Lua. ( Hence this function is not available ).

While we are in the script TriggerNode could trigger a different lua script while the first is still running,.. I am not sure what would happen then. I will have to think of a way to solve this.

danward79
October 5th, 2005, 10:35 AM
Do I have t use the "OnApply" event to save the lvalue's somewhere?

They do not appear to be saving on there own

Ron
October 5th, 2005, 10:40 AM
In the designer set those controls NOT to Lua controls but to lValue1 (L) etc. Or use Lua and save the values in

Action.lValue1=Control.ID
Action.FileGUID1=Control.FileGUID

during OnApply.

danward79
October 5th, 2005, 10:54 AM
ummm,


In the designer set those controls NOT to Lua controls but to lValue1 (L) etc.

That is what I have done.

Then when I test it. I chose a node from the list click apply. It shows in the form which nod is there. However when I go back into the action it is blank?

I have attached my files for you to see. Only look at the "does file exist" action.

I dunno why I am being so "thick" today. I guess it is a serious lack of sleep. The baby is sick. :cry: :cry:

Ron
October 5th, 2005, 10:58 AM
I'll investigate later. Pretty busy hammering out the bug in B9 that is causing everyone headaches.

danward79
October 5th, 2005, 11:09 AM
No Worries,

danward79
October 5th, 2005, 12:44 PM
Ok, That is how tired I am I did not notice the "i" was not an "l" in the dui, I thought it was an "l". :o

However I still need to be able to trigger an event / action in a gml from it.

Ron
October 5th, 2005, 12:45 PM
Note you are mixing up 2 things here.

Triggering an Event

and

Triggering a Node.

The first is possible and does not use the lValue's. The second is not possible (at the moment) for reasons I mentioned above.

danward79
October 5th, 2005, 12:52 PM
I guess, if this is for everyone to use it will need to do the latter or both.

Is there any work around I could use? or something I could do in the meantime as a temporary measure?

I suppose I could use just the former for now.

Ron
October 5th, 2005, 12:55 PM
Right now there is not much we can do. You'll have to wait for an update.

danward79
October 5th, 2005, 12:57 PM
Thanks, I have the other actions to work on for now.

Thanks for the help.

danward79
October 9th, 2005, 10:52 AM
Hi,

I have, I think finished. Subject to your testing and future addition to girder so I can call a node. etc.

I was not able to implement "Does File Exist" or "Does Folder Exist" fully yet because I can not call a gml node from lua.

Could you have a look over / try it out and let me know if it is ok?

I am sure I have probably missed something stupid! :P

danward79
October 20th, 2005, 06:58 AM
Mike / Ron,

Did you try these yet?

Ron
October 20th, 2005, 01:59 PM
Sorry Dan I am pretty busy with the regular Girder stuff, I'll try and sneak this in at some point.

danward79
October 20th, 2005, 09:13 PM
NP

danward79
November 10th, 2005, 01:00 PM
Mike / Ron...

Did you have a chance to look at this yet?

If it is ok, I can give it up for general release?

Promixis
November 10th, 2005, 05:22 PM
looks nice, my quick testing seems fine. great stuff to have on the tree.

danward79
November 11th, 2005, 01:02 AM
Yep, There is one action I did not include due to being unable to execute a node in the tree, yet. When Ron adds it I can add that.

In the mean time there it is then. Do you want to add it to the install? or should I put it on the plugin page?

danward79
December 2nd, 2005, 04:10 AM
Note you are mixing up 2 things here.

Triggering an Event

and

Triggering a Node.

The first is possible and does not use the lValue's. The second is not possible (at the moment) for reasons I mentioned above.

Ron,

Is it possible to trigger nodes yet from the actions tree?

I just tried it did not work or is it me being thick!? :)

danward79
May 24th, 2006, 01:28 PM
Hi,

I have finally finished updating this to now include checking for a folder or file and triggering a node, I have uploaded it to the download section.

Hope it is useful for someone.

danward79
May 25th, 2006, 09:13 AM
Hi,

I have now updated this to include a file and folder conditional

Should be in the download section as soon as it is approved.

Ron
May 25th, 2006, 09:19 AM
I didn't recheck this now, but I assume it worked when I wrote it :-)

gir.TriggerNode(string GUID, number nodeid, boolean ParentCheck);

danward79
May 25th, 2006, 10:22 AM
I didn't recheck this now, but I assume it worked when I wrote it :-)

gir.TriggerNode(string GUID, number nodeid, boolean ParentCheck);

Yeah all good now, Thanks Ron!

Ron
May 25th, 2006, 01:03 PM
Just noticed that your question was from December, well can't accuse me that I don't answer questions :-)

vince_b
December 5th, 2006, 04:52 PM
Hey, thanks for these functions, just what I needed!

edit- Can I call these from lua? Would be perfect then rather than cascading events to get if..elseif functionality. Thanks!

danward79
December 5th, 2006, 08:55 PM
Hi,

Yes you can call them from lua check the variable view for the file list this shows all the functions available.

sirbooker
June 4th, 2008, 08:16 AM
i am using this plugin in G5 and would like to rename a file from my webcam dir, the problem is the image file name changes evey time a image is captured eg,,, it's name is the date and time the pictured was captured.
how can i rename this file when the name changes everytime
i tried *.jpg but it doesn't work
is there no wildcard support !!
any ideas ???

Thanks
paul.

danward79
June 4th, 2008, 09:23 AM
No Sorry, I never implemented the wildcard support. You could try writing some lua scripts to handle this.