quanticworks | 27 May 2012 03:08
Picon

info label with scrolling string

Hi,

I've tried w/o success to set up a button to scroll foobar2k caption within a info label

in the below msg bruce, you posted a script which is not working for me. It gives an error msg: "Mod by 0"

http://tech.dir.groups.yahoo.com/group/power-pro/message/26109?threaded=1&p=5

anyway, I'd like to use event to better control the scrolling time.

what is the format to achieve that?
Note:
I'll be using it in a script, so:
.SetLabel(0, "Info expr(

also, does the event need to be destroyed or it destroys itself after program closes?

------------------------------------

PowerPro's download site: http://powerpro.webeddie.com/Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/power-pro/join
    (Yahoo! ID required)
(Continue reading)

cy_lists_2011 | 27 May 2012 11:59
Favicon

Re: info label with scrolling string

This is an old script, it does basically the same thing as Bruce's script.
HTH

 <at> ScrollingBar
     Local _barName = "bar_Scroller"
     cl.Create(_barName, 1)
     cl.SetProperties(_barName, "Format1 = AutoShowBar barsize TopMost 
Tooltips Position: FixedBottomCenter")
     cl.AddProperties(_barName, "FontName = Lucida Console")
     cl.AddProperties(_barName, "FontInfo = Bold Size: 8")
     cl.AddProperties(_barName, "BackBMP = none")

     Global gvScrText = "Welcome to the jungle, we got fun and games!"
     Global gvScrLen = length(gvScrText)

     cl.Insert(_barName, 0)

     cl.SetWidth (_barName, 0, 35*8)
     cl.SetHeight(_barName, 0, 35)
     cl.AddRight (_barName, 0, ".test <at> test")
     cl.SetLabel (_barName, 0, ?#*Info expr(select(gvScrText ++ " " ++ 
gvScrText, 1 + timesec % gvScrLen, 35 + timesec % gvScrLen))#)

     Bar Show bar_Scroller
     Quit

quanticworks wrote  (on 27.05.2012 03:08):
>
> Hi,
>
(Continue reading)

brucexs | 27 May 2012 13:11
Picon
Favicon

Re: info label with scrolling string

This would be the best script to use as a model for what you are trying to do.

Note that there is no event.  Instead, the rotation is based on the timesec function, which will increase by
one (second) each time the label is redisplayed.  The reason is that *info updates once per second, and the
timesec function will have increased by one in that time.

The script uses the modulus operator a % b which returns the remainder when a is divided by b.  In this case b is
the length of the string being displayed.  The "mod by zero" error message indicates the string being
displayed had zero length -- it was likely uninitialized.

This technique is simple but limited
- always one character rotate per second
- starting point depends on what timesec happens to be % the string length at the start (although you can add a
constant offset in the script which sets up the label which is calculated to make it start at the beginning
of the string)

It should be possible to do a more flexible version with events and the cl functions to get, rotate, then
reset the label (and avoid *info and timesec), but it would be trickier to program.   You may also have to
reshow the bar to get the new label to show -- not sure about that.

--- In power-pro@..., cy_lists_2011 <at> ... wrote:
>
> This is an old script, it does basically the same thing as Bruce's script.
> HTH
> 
> 
>  <at> ScrollingBar
>      Local _barName = "bar_Scroller"
>      cl.Create(_barName, 1)
>      cl.SetProperties(_barName, "Format1 = AutoShowBar barsize TopMost 
(Continue reading)

quanticworks | 22 Jun 2012 01:49
Picon

Re: info label with scrolling string

Thank you both for the help!

I tried the script and it worked with the text supplied, then I adapted it to give me foobar2000 caption and it
shows the title rotating but it doesn't update when track changes...

-------start-------

local sl = cl.Create("ScrollingLabel", 1)

sl.SetProperties("FontName = Lucida Console \r FontInfo = Bold Size: 8 \r ;;+
Position: Floating AutoShowBar BarSize TopMost")

global str = win.Caption("c={97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}")
global strLen = length(str)

sl.Insert(0).AddLeft("bar close ScrollingLabel").SetHeight(35).SetWidth (35*8);;+
.SetLabel (?#*Info expr(select(str ++ " " ++  str, 1 + timesec % strLen, 35 + timesec % strLen))?#)

sl.Show
quit

-------end-------

I guess I could add the script to the monitor list in order to update it but I want to do it all within the same script.

Bruce, as you clearly explained how it works, it doesn't sound like a good solution... I mean, updating one
character rotation per second seems unnecessary to me. 
The event solution as you described, also seems too much...

Isn't there a clean and more elegant way to achieve this?
(Continue reading)

brucexs | 22 Jun 2012 12:31
Picon
Favicon

Re: info label with scrolling string

The only way I know to do animation is with a timer and a slightly changing image -- that is how movies work, and
also the windows animation that slides in hidden bars.

The main advantage of events over *info is that they let you control the refresh interval.  If once per second
is enough, you don't need it.

You don't need a monitor list if you have the *info call a script.  That script will get called once per second
by the way *info works.  It can keep track of the original caption in a static and check to see if it has changed.

Post if you want more details on how to write such a script.

--- In power-pro@..., "quanticworks" <quanticworks <at> ...> wrote:
>
> Thank you both for the help!
> 
> I tried the script and it worked with the text supplied, then I adapted it to give me foobar2000 caption and
it shows the title rotating but it doesn't update when track changes...
> 
> -------start-------
> 
> local sl = cl.Create("ScrollingLabel", 1)
> 
> sl.SetProperties("FontName = Lucida Console \r FontInfo = Bold Size: 8 \r ;;+
> Position: Floating AutoShowBar BarSize TopMost")
> 
> global str = win.Caption("c={97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}")
> global strLen = length(str)
> 
> sl.Insert(0).AddLeft("bar close ScrollingLabel").SetHeight(35).SetWidth (35*8);;+
> .SetLabel (?#*Info expr(select(str ++ " " ++  str, 1 + timesec % strLen, 35 + timesec % strLen))?#)
(Continue reading)

quanticworks | 23 Jun 2012 00:45
Picon

Re: info label with scrolling string

Please do Bruce. I appreciate it!

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> The only way I know to do animation is with a timer and a slightly changing image -- that is how movies work,
and also the windows animation that slides in hidden bars.
> 
> The main advantage of events over *info is that they let you control the refresh interval.  If once per
second is enough, you don't need it.
> 
> You don't need a monitor list if you have the *info call a script.  That script will get called once per second
by the way *info works.  It can keep track of the original caption in a static and check to see if it has changed.
> 
> Post if you want more details on how to write such a script.
> 
> 
> 
> --- In power-pro@..., "quanticworks" <quanticworks <at> > wrote:
> >
> > Thank you both for the help!
> > 
> > I tried the script and it worked with the text supplied, then I adapted it to give me foobar2000 caption and
it shows the title rotating but it doesn't update when track changes...
> > 
> > -------start-------
> > 
> > local sl = cl.Create("ScrollingLabel", 1)
> > 
> > sl.SetProperties("FontName = Lucida Console \r FontInfo = Bold Size: 8 \r ;;+
> > Position: Floating AutoShowBar BarSize TopMost")
(Continue reading)

cy_lists_2011 | 24 Jun 2012 20:30
Favicon

Re: Re: info label with scrolling string

quanticworks wrote  (on 22.06.2012 01:49):
>
> I tried the script and it worked with the text supplied, then I 
> adapted it to give me foobar2000 caption and it shows the title 
> rotating but it doesn't update when track changes...
>
> -------start-------
>
> ...
> global str = win.Caption("c={97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}")
> global strLen = length(str)
>

The reason why the title's not updating, is probably you are not 
re-setting "str" & "strLen" when the track changes.

I used to do this with the special Monitor script, i.e. querying the 
title every sec, comparing it to the last known one (via static 
variable), and if changed, doing changes to the bar, and refreshing it. 
But mind you this consumes too much CPU just for this purpose. You might 
wanna try AMIP, which can call external programs, e.g. a PowerPro 
script, to refresh this info on track change.
http://amip.tools-for.net/wiki/manual/amip

[Non-text portions of this message have been removed]

------------------------------------

PowerPro's download site: http://powerpro.webeddie.com/Yahoo! Groups Links

(Continue reading)

brucexs | 24 Jun 2012 23:34
Picon
Favicon

Re: info label with scrolling string


I had a bit of fun on this, and came up with a script that allows you to set the refresh interval and checks to see
if the base text has changed on each refresh.  I hope it is not overkill for you.

The script can also handle many different bar buttons at once, although all have to be updated at the same
rate.  The buttons don't have to be on the same bar.

I've attached the script at the bottom of this note.  Save it into a script file called RotateIt.txt (or .powerpro)

To use it, you first have to create one or more command lists to display the rotating text.  Assign an id to each
command list item that you want to display rotating text (the id field in the command list item edit dialog).

Then register each button to have rotated text with this call
.rotateIt("clistname", "id", ?%expression for text%)

where ?%expression for text% is an expression that yields the text to be rotated.  Use the ?%...% string so
you can use "..." in the expression.  Examples

.rotateIt("rotate","fb", ?%win.caption("=foobar2000").remove(-19)%) 

would set the button labelled "fb" on the bar "rotate" to show whatever foobar is playing (the remove gets
rid of the foobar constant title at the end).

.rotateIt("rotate", "date", ?%longdate ++" "++  time%)  
sets up a button "date" on the same bar with the date and time

When you call rotateIt, nothing is displayed.  But the script does try to evaluate your expression.  If you
see an error, it means the expression has bad syntax.

You can test the expression by executing
(Continue reading)

quanticworks | 25 Jun 2012 20:46
Picon

Re: info label with scrolling string

Bruce, thank you for taking the time to do this!
I had a quick test run to see it working but it's blank, need to read your message with more attention to see if I
skipped something

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> 
> I had a bit of fun on this, and came up with a script that allows you to set the refresh interval and checks to
see if the base text has changed on each refresh.  I hope it is not overkill for you.
> 
> The script can also handle many different bar buttons at once, although all have to be updated at the same
rate.  The buttons don't have to be on the same bar.
> 
> I've attached the script at the bottom of this note.  Save it into a script file called RotateIt.txt (or .powerpro)
> 
> To use it, you first have to create one or more command lists to display the rotating text.  Assign an id to
each command list item that you want to display rotating text (the id field in the command list item edit dialog).
> 
> Then register each button to have rotated text with this call
> .rotateIt("clistname", "id", ?%expression for text%)
> 
> where ?%expression for text% is an expression that yields the text to be rotated.  Use the ?%...% string so
you can use "..." in the expression.  Examples
> 
> .rotateIt("rotate","fb", ?%win.caption("=foobar2000").remove(-19)%) 
> 
> would set the button labelled "fb" on the bar "rotate" to show whatever foobar is playing (the remove gets
rid of the foobar constant title at the end).
> 
> .rotateIt("rotate", "date", ?%longdate ++" "++  time%)  
(Continue reading)

quanticworks | 26 Jun 2012 01:36
Picon

Re: info label with scrolling string

Ok, figured it out why it was blank...
you used win.caption("=foobar2000") and this doesn't work when the player is trayminned. that's why I use
its class instead.
working fine now!

let me just say that I'm glad you had fun coding this, always great to hear that.
the script idea its very cool and gives interesting thoughts about some configs :), however I did noticed a
bit more cpu and memory usage increase.
is it possible to optimize it in any way bruce or is this the reality of text animation and we can't avoid it?

--- In power-pro@..., "quanticworks" <quanticworks <at> ...> wrote:
>
> Bruce, thank you for taking the time to do this!
> I had a quick test run to see it working but it's blank, need to read your message with more attention to see if
I skipped something
> 
> 
> 
> --- In power-pro@..., "brucexs" <brucexs <at> > wrote:
> >
> > 
> > I had a bit of fun on this, and came up with a script that allows you to set the refresh interval and checks to
see if the base text has changed on each refresh.  I hope it is not overkill for you.
> > 
> > The script can also handle many different bar buttons at once, although all have to be updated at the same
rate.  The buttons don't have to be on the same bar.
> > 
> > I've attached the script at the bottom of this note.  Save it into a script file called RotateIt.txt (or .powerpro)
> > 
> > To use it, you first have to create one or more command lists to display the rotating text.  Assign an id to
(Continue reading)

brucexs | 26 Jun 2012 16:05
Picon
Favicon

Re: info label with scrolling string

Of course, PowerPro is a slow, scripting interpreter, so it is never going to be fast or efficient.

But one possible optimization in the script is to avoid checking the source info every time you update.

If you used the script with 250 ms update, the source text is checked 4 times a second.

If you were willing to live with (say) once every 2 seconds, but still wanted to rotate 4 times a second, you
could optimize the script to see if that helped.

Here are some ideas on how to do this.  A good learning experience, but if you are not comfortable with the
scripting, post and I will try.

IN the rotateit function cache the current text as well as the expression for updating, something like:
State[clist ++ "\x01" ++ id] = "0" ++ "\x01" ++ baseExpr++"\x01"++text

Now in the update function, split the State value back into its three parts, not two as current.

Keep a static counter in update.  Add one on each call.  If it becomes greater than (say) 8, set it back to 1.  

Whenever it is 1 (make sure this happens on first call), then evaluate the expression and reset the cached
text to that expression.  

If it is not 1, just use the cached text.

Put all back in the State when done using same statement as used in rotateit.

--- In power-pro@..., "quanticworks" <quanticworks <at> ...> wrote:
>
> Ok, figured it out why it was blank...
> you used win.caption("=foobar2000") and this doesn't work when the player is trayminned. that's why I
(Continue reading)

quanticworks | 30 Jun 2012 10:13
Picon

Re: info label with scrolling string

I've the will to learn but lack the skills needed to do what you suggest.
I'm still at a very beginner state in regards to scripting.
If you want to try it, give it a go but if you think the revised code will not improve much, then don't bother. I
appreciate a lot the time you've spent with this already.

Any suggestions where I can understand/learn some logic?
I've said in other post that I prefer minimal code, so what would be my best option to gather knowledge in
writing such code?

I like chained commands, short forms, local vars, compound assignment etc...
don't like many repeats like:
cl.setproperties(barname
cl.insert(barname
cl.addleft(barname
cl.setlabel(barname

that's why I use:

local hlist = cl.create("clname",1)
hlist.setprops().insert().addleft().setlabel().show

and instead of:

mycounter = mycounter + 1  

I prefer:

myc+=1

myc++ (is this form available in powerpro or will it be interpreted as "join" w/o assignment?)
(Continue reading)

brucexs | 30 Jun 2012 18:55
Picon
Favicon

Re: info label with scrolling string


--- In power-pro@..., "quanticworks" <quanticworks <at> ...> wrote:
>
> I've the will to learn but lack the skills needed to do what you suggest.
> I'm still at a very beginner state in regards to scripting.
> Any suggestions where I can understand/learn some logic?

From the sample syntax you post and the questions you ask, you seem to have a very sophisticated
understanding of the PowerPro scripting syntax.

So I am going to interpret your question to mean that you would like some suggestions how to learn more about
programming in general.  Let me know if I missed what you are asking.

I suggest the Udacity courses.  They use Python.  Basic python is well worth learning and similar to PowerPro
scripting in spirit (unlike say Ruby).  Of course, Python is in another league compared to PowerPro (or
more realistically, Python is major leagues and PowerPro level A ball).

In any event, the courses are here.

http://www.udacity.com/courses

I'd start with 101, and then move on to the algorithms 215, and, if you are having fun, move on to Peter
Norvig's course 212.

Now I have only done 212; I have not taken 101 or 215.  I learned Python from the Google Code University course
which is good and helps you set your computer up for running Python.  Since I have not taken 101, I am not sure
how much Python it assumes.  I'd start with it, and only go to Google if it requires Python knowledge to start
the 101 course.  You might also want to look at the Google site to learn abou setting up python, which is very
helpful for more advanced Udacity courses.  (They have a web interface to run Python which means you might
not need it for 101).
(Continue reading)

quanticworks | 1 Jul 2012 04:43
Picon

Re: info label with scrolling string

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:

> From the sample syntax you post and the questions you ask, you seem to have a very sophisticated
understanding of the PowerPro scripting syntax.

not that much really, but I study it a lot.

> 
> So I am going to interpret your question to mean that you would like some suggestions how to learn more about
programming in general.  Let me know if I missed what you are asking.

You understood right, however this was included in my question:
http://en.wikipedia.org/wiki/Logic

> 
> I suggest the Udacity courses.  They use Python.  Basic python is well worth learning and similar to
PowerPro scripting in spirit (unlike say Ruby).  Of course, Python is in another league compared to
PowerPro (or more realistically, Python is major leagues and PowerPro level A ball).
> 
> In any event, the courses are here.
> 
> http://www.udacity.com/courses
> 
> I'd start with 101, and then move on to the algorithms 215, and, if you are having fun, move on to Peter
Norvig's course 212.
> 
> Now I have only done 212; I have not taken 101 or 215.  I learned Python from the Google Code University course
which is good and helps you set your computer up for running Python.  Since I have not taken 101, I am not sure
how much Python it assumes.  I'd start with it, and only go to Google if it requires Python knowledge to start
the 101 course.  You might also want to look at the Google site to learn abou setting up python, which is very
(Continue reading)

brucexs | 2 Jul 2012 17:15
Picon
Favicon

Re: info label with scrolling string


> 
> You understood right, however this was included in my question:
> http://en.wikipedia.org/wiki/Logic

That article is on math logic which is not really applicable to day-to-day programming (it is for
theoretical computer science).

Th udacity courses are great for learning because they have a lot of interactive quizzes and programming
assignments.  

> 
> thanks for the clarification on the service .show and I'm glad it's simple enough for you to implement it.
> this means that we'll be able to use not only .show but other functions as well, like HideShow, etc...
right?  
> 

Yes, any list service will work.

I put getparentlist() into 4.9p7, but forgot to test.  You can try it if you want.

------------------------------------

PowerPro's download site: http://powerpro.webeddie.com/Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> Your email settings:
    Individual Email | Traditional
(Continue reading)

quanticworks | 3 Jul 2012 01:25
Picon

Re: info label with scrolling string

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> 
> > 
> > You understood right, however this was included in my question:
> > http://en.wikipedia.org/wiki/Logic
> 
> That article is on math logic which is not really applicable to day-to-day programming (it is for
theoretical computer science).
> 
> Th udacity courses are great for learning because they have a lot of interactive quizzes and programming
assignments.  
> 

reading too much lately, better focus on the courses.

> > thanks for the clarification on the service .show and I'm glad it's simple enough for you to implement it.
> > this means that we'll be able to use not only .show but other functions as well, like HideShow, etc...
right?  
> > 
> 
> Yes, any list service will work.
> 
> I put getparentlist() into 4.9p7, but forgot to test.  You can try it if you want.
>

working good bruce, thanks!

------------------------------------

(Continue reading)

brucexs | 15 Jul 2012 17:39
Picon
Favicon

Re: info label with scrolling string

Here is the update I promised which only refreshes the rotating string.  every 8 rotations (ie once every two
seconds if you are rotating 4 times a second).

I notice that a couple of lines are wrapped by Yahoo, so be careful (eg ones with ++ text at the end).

I did not notice any difference in cpu usage from the case where it refreshes every time.  In both cases, task
manager shows 0 usage for PPro. I know that is not the most accurate way, but it really seems accurate to
conclude that on my machine there is not much difference.  Your machine may be different.

;; ----------------------------Store info needed by update event
Function rotateIt(clist, id, baseExpr)

;; State is a map of all the text expressions being rotated
;; Key: the clist name ++ "\x01" ++ id of button where text to be written
;; Value: the current rotation number ++ "\x01" ++  the expression evaluated to get the text to be rotated

static State

if (not map.exists(State)) 
	State = map.create(32)
	
local text = eval(baseExpr) ++ " " ;; to display any syntax errors before we store
State[clist ++ "\x01" ++ id] = "0" ++ "\x01" ++ baseExpr ++ "\x01" ++ text
EndFunction

;; ------------------------Create the event which drives all rotations */
Function Start(interval)
interval = max(50, min(2000, interval))
static theEvent
static counter = 0
(Continue reading)

quanticworks | 5 Aug 2012 04:59
Picon

Re: info label with scrolling string

--- In power-pro@..., "brucexs" <brucexs <at> ...> wrote:
>
> Here is the update I promised which only refreshes the rotating string.  every 8 rotations (ie once every
two seconds if you are rotating 4 times a second).
> 
> I did not notice any difference in cpu usage from the case where it refreshes every time.  In both cases, task
manager shows 0 usage for PPro. I know that is not the most accurate way, but it really seems accurate to
conclude that on my machine there is not much difference.  Your machine may be different.
> 

finally tested the revised script and let me say, awesome revision bruce!
although you didn't saw any difference in your machine, it was enough in mine, which now runs with barely any impact.

Thank you! 

------------------------------------

PowerPro's download site: http://powerpro.webeddie.com/Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/power-pro/join
    (Yahoo! ID required)

<*> To change settings via email:
(Continue reading)

quanticworks | 25 Jun 2012 20:44
Picon

Re: info label with scrolling string

Hi descent49,

I did try many options to check the caption state but didn't liked the outcome and the possible overhead it'd
cause. 
I like minimal code.
If there's a simpler way to do something I'm all for it, problem is, powerpro must do it all! :D so AMIP (I have
used it some years ago) is a no go but many thanks for your help!
I'll try bruce's script...

--- In power-pro@..., cy_lists_2011 <at> ... wrote:
>
> quanticworks wrote  (on 22.06.2012 01:49):
> >
> > I tried the script and it worked with the text supplied, then I 
> > adapted it to give me foobar2000 caption and it shows the title 
> > rotating but it doesn't update when track changes...
> >
> > -------start-------
> >
> > ...
> > global str = win.Caption("c={97E27FAA-C0B3-4b8e-A693-ED7881E99FC1}")
> > global strLen = length(str)
> >
> 
> The reason why the title's not updating, is probably you are not 
> re-setting "str" & "strLen" when the track changes.
> 
> I used to do this with the special Monitor script, i.e. querying the 
> title every sec, comparing it to the last known one (via static 
> variable), and if changed, doing changes to the bar, and refreshing it. 
(Continue reading)


Gmane