Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Problem storing Tagz in a variable (Read 1980 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Problem storing Tagz in a variable

I'm having a problem putting "%_time_elapsed_seconds%,%_time_total_seconds%" into a variable and using them later on.  Maybe a bug, normal behavior, or me.

Here's my sad story

I wanted to display a progress bar in the status bar using variables

This version works:

//Store Progress Bar
$progress(%_time_elapsed_seconds%,%_time_total_seconds%,20,|,'—')

So, I wanted to store %_time_elapsed_seconds% and %_time_total_seconds% in a variable

I did this:

//Store Time in Seconds
$puts(time_secs,%_time_elapsed_seconds%[,%_time_total_seconds%])


Using the $Get below, the times stored above display correctly

//Display Time
$get(time_secs)

Then I put the progress bar into a variable (without the time_secs variable) and tried to display that

// Store progress bar
$puts(progress_bar, $progress(%_time_elapsed_seconds%,%_time_total_seconds%,20,|,'—'))

//Display progress bar
$get(progress_bar)

and that worked just fine

Finally I put the variable into the progress_bar variable

//Store Progress Bar
$puts(progress_bar,$progress($get(time_secs),20,|,'—'))

And tried to display the entire thing

//Display Progress Bar
$get(progress_bar)

But it won't display.  It just returns a null.

Can anyone else repeat this or did I screw up somewhere?
Master of Fate. By Fate Mastered

Problem storing Tagz in a variable

Reply #1
I think the problem is the same thing that prevents someone from creating a true function with $puts/$get.

The issue is that strings which are put into variables are only evaluated once, at creation time.

So when you put the $progress() function into a variable, it is only storing the string outputted by $progress, not the actually code itself.  Thus, every time you call the variable with $get, you get that exact same string that $progress evaluated when your PROGRESS_BAR variable was created.  This means that even though the time elapsed tags are changing, only the very first value is being used each time you call $get.

I'm not 100% sure of this because I don't know how the status bar tagz display is setup internally, but I'm fairly certain this is the cause.

Edit:  Just reread your post and what I said must not be the case actually since you were able to get

Code: [Select]
$puts(progress_bar, $progress(%_time_elapsed_seconds%,%_time_total_seconds%,20,|,'—'))


... to work.

It seems maybe the problem is that with:

Code: [Select]
$puts(progress_bar,$progress($get(time_secs),20,|,'—'))


... you are only passing 4 parameters to $progress when is expecting 5.  I don't think that your comma seperating in creating the time_secs variable is actually being evaluated as two parameters.  Try breakign it up into two seperate variables and it should work.

Problem storing Tagz in a variable

Reply #2
I think you may be right about the number of parameters it's seeing.  But....

If you do:

Quote
//Store Time in Seconds
$puts(time_secs,%_time_elapsed_seconds%[,%_time_total_seconds%])

//Display Time
$get(time_secs)

It'll display as 'nnn,nnn' i.e. the comma is there.


Anyway, doing it this way does work
Quote
$puts(tes, %_time_elapsed_seconds%)

$puts(tts, %_time_total_seconds%)

$puts(progress_bar,$progress($get(tes),$get(tts),20,<$get(color_red)$get(time_percent)'%'$get(color_black)>,'—'))


Unfortunately, you're not really buying anything this way
Master of Fate. By Fate Mastered

 
SimplePortal 1.0.0 RC1 © 2008-2021