Page 1 of 2

Execute two commands at the same time

Posted: Tue Jan 24, 2017 9:16 pm
by mrcoollion
Is there any way to have two (or more) commands executed at the same time.
What I want to do is to show / hide two fields at the same time with visual effects.

I have been looking at broadcasting but cannot figure that out (need GLX framework plugin ect....)

Regards,

Paul

Re: Execute two commands at the same time

Posted: Tue Jan 24, 2017 9:40 pm
by Klaus
Goedenavond Paul,

sounds like you are looking for something like this:
...
lock screen for visual effect
hide fld 1
hide fld 2
unlock screen with visual effect dissolve
...
Right?


Best

Klaus

Re: Execute two commands at the same time

Posted: Tue Jan 24, 2017 10:05 pm
by mrcoollion
Goedenavond Klaus,


What I want to do is push up text in a field by using visual effect push up.
In this case for showing a RSS feed (as a test) because the push up affect is nice and smooth.
To give the user the idea that the new text pushes the old text up I need to hide one field with visual effect push up and at the same time show the second field with visual effect push up.
Both fields are transparent and a third field provides the background color.
I does work after each other but that leaves a gap because the show field action is only started after the hide field action is done.

(I know I could do something similar with moving of fields behind objects with a higher layer number and use lockMoves but it is not the way i want to go for now)

Code: Select all

Hide fld "RSS_1" with visual effect push up
Show fld "RSS_2" with visual effect push up

Re: Execute two commands at the same time

Posted: Tue Jan 24, 2017 10:37 pm
by Klaus
Sorry, but we can only have one visual effect at a time.

However you could (only) "fake" a dissolve effect by setting the fields blendlevel in a repeat loop.
Know what I mean?

Re: Execute two commands at the same time

Posted: Tue Jan 24, 2017 11:43 pm
by dunbarx
How about this. Make a button and a field on a new card. Put some text into the field, maybe even a couple of lines. Size the field so you can read all. In the button script:

Code: Select all

on mouseUp
   set the topMargin of fld 1 to 25
   repeat with y = 5 to 100
      set the topMargin of fld 1 to the topMargin of fld 1 - 1
      wait 1
   end repeat
end mouseUp
You can overlay two transparent fields and run a slightly embellished handler in such a way that the text of one chases the other upwards. Just manage the margins. This can even read the contents of the fields, and determine for themselves what values to take.

Craig Newman

Re: Execute two commands at the same time

Posted: Wed Jan 25, 2017 4:51 pm
by mrcoollion
I have to work tonight but will give it a try asap and let you know.

Re: Execute two commands at the same time

Posted: Wed Jan 25, 2017 5:22 pm
by Klaus
Dag Paul

I think this might please you:

Code: Select all

on mouseUp
   lock screen for visual effect in rect (the rect of fld "RSS_1")
   Hide fld "RSS_1" 
   Show fld "RSS_2"
   unlock screen with visual effect push up
end mouseUp
Will do exactly what you described! :D


Groetjes

Klaus

Re: Execute two commands at the same time

Posted: Wed Jan 25, 2017 9:37 pm
by mrcoollion
Wow Klaus,
It actually does what i intended to a achieve... kudo's to you .. took some experimenting I guess :D
Thanks.

Also the solution from Craig works pretty good and has it benefits..... however it needs to run non blocking ...

Thanks guy's ......


PS. Still would like to know how to have two handlers (command A and Command B) do their thing at the same time if at all possible.. (Broadcasting ?)

Re: Execute two commands at the same time

Posted: Wed Jan 25, 2017 11:47 pm
by Klaus
mrcoollion wrote:PS. Still would like to know how to have two handlers (command A and Command B) do their thing at the same time if at all possible.. (Broadcasting ?)
Since Lc is single-threaded, this is not be possible at all.
But depending on the task, you might be able to "fake" this functionality. 8)

Re: Execute two commands at the same time

Posted: Thu Jan 26, 2017 12:33 am
by dunbarx
Hi.

Glad you have a way forward. As for blocking, simply change to "wait 1 with messages".

And as Klaus noted, since LC is single threaded, you will have to write your double handler as a single handler. but I bet with a little planning this can always be worked out.

Craig

Re: Execute two commands at the same time

Posted: Thu Jan 26, 2017 8:23 am
by mrcoollion
Thanks .. 8)

Re: Execute two commands at the same time

Posted: Thu Jan 26, 2017 9:27 pm
by mrcoollion
So with the knowledge gained I made a simple RSS feed ticker that really scrolls very smooth compared the way I did it previously ( delete first character of ... in a repeat loop)

Set up a field named "RSS-ticker" with following settings (you figure out why :wink: )
RSS Field settings: sharedText=false;DontWrap=true;lockText=true;opaque=true;traversalOn=false;listBehaviour=true

Put the code below in a button and run it.

Code: Select all

on mouseUp
    //===Get the RSS feed (in this case the biggest dutch news site) ======================================================================
    get url "http://www.nu.nl/rss/Algemeen"
    put it into myXML
    put revCreateXMLTree(myXML, false, true, false) into tTree
    if tTree is not an integer then
        answer "Error with revCreateXMLTree !"
        exit mouseUp
    end if
    --
    // we can directly access nodes
    put revXMLNodeContents(tTree, "rss/channel/title") && "-" && revXMLNodeContents(tTree, "rss/channel/description") into tTitleAndDescr -- this will out put sites title and description
    put tTitleAndDescr & " .... " into RSSText
    --
    put revXMLChildNames(tTree, "rss/channel/", return, "item", true) into recentPosts
    repeat for each line aPost in recentPosts
        put revXMLNodeContents(tTree, "rss/channel/" & aPost & "/title") into postTitle
        put revXMLNodeContents(tTree, "rss/channel/" & aPost & "/link") into postLink
        put postTitle & " .... " after RSSText
    end repeat
    --
    put empty into field "RSS-ticker"
    set the htmltext of field "RSS-ticker" to RSSText 
    // == Show the RSS feed text in the RSS-ticker field ==========================================================================
    put the number of characters of fld "RSS-ticker"  into tNbrOfCharacters
    // Find out the witdth of the text to stop the repeat loop after the last character.
    repeat with tCounter =1 to tNbrOfCharacters
        put the formattedWidth of Char tCounter of fld "RSS-ticker" into tCharWidth
        add tCharWidth to tTheWidth
    end repeat
    put the width of fld "RSS-ticker" into tFldWidth
    put tFldWidth into tStartLeftmargin
    put tTheWidth +tStartLeftmargin into tRepeatNumber
    set the leftMargin of fld "RSS-ticker" to tStartLeftMargin
    put "---------------------------------------------------------" after RSSText // Want to stop the ticker showing this to prove the repeat loop stops exactly where i want.
    set the htmltext of field "RSS-ticker" to RSSText 
    repeat with y = 1 to tRepeatNumber 
        set the leftMargin of fld "RSS-ticker" to the leftMargin of fld "RSS-ticker" - 1
        wait 0.5 with messages // Speed control
    end repeat
    wait 3 seconds
    set the leftMargin of fld "RSS-ticker" to 8
    //========================================================================================
end mouseUp


Thanks again......

Paul

Re: Execute two commands at the same time

Posted: Tue Jan 31, 2017 3:26 pm
by mrcoollion
I found one issue with the Klaus solution when using

Code: Select all

lock screen for visual effect in rect (the rect of fld "RSS_1")

The problem is that during the lock screen it locks all user input in the screen and not only within the the rect of fld "RSS_1" .
Any way to solve this?

Regards,

Paul

Re: Execute two commands at the same time

Posted: Tue Jan 31, 2017 5:27 pm
by Klaus
Hi Paul,

any visual effect is completely blocking, if it happens in a rect or over the complete card!


Best

Klaus

Re: Execute two commands at the same time

Posted: Tue Jan 31, 2017 8:59 pm
by mrcoollion
Vielen Dank Klaus,

It is good to know......