IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Use of Varibles in Export Scripts, Export Scripting
PDWhite
post Dec 2 2016, 20:53
Post #1


Member


Group: Members
Posts: 4
Joined: 27-November 16
From: Houston, Texas USA
Member No.: 22760
Mp3tag Version: 2.80



I am attempting to create an export script that uses variables to sum up %length% values as each %track% loop occurs. I am converting the current length to seconds as a $num(x,n) succesfully, and placing it in a variable. However I still can't find a way to add the next track's %length% value to it. $add doesn't appear to work on user variables, and there is no real documentation on variables and how they can be used.

If anyone has notes on variable use or could reply with the proper script syntax to do the things below, I would be very grateful.

Generally, Variable1 loaded using $put(SLEN,($num(%_length_seconds%,5))), using Variable2 as the running total, by adding %_length_seconds% or Variable1 with the running sum of the loops.

%add() used with or without $num does not appear to work.

I could probably use %_total_time_seconds% without modifiacation, but it actually decrements total time by %_length_seconds% on each pass through the loop, which is the opposite of I would expect.

One more confusing area: If I load a variable using $put(SLEN,($num(%_length_seconds%,5))), which results in a $get value shown as "(nnnnn)", whereas using %_total_time% displays nn:nn:nn.

More confusing is $num(%_total_time_seconds%,5) which yields 000000

I understand that this is all 'very electric and dangerous,' but if you have a reference or can show an example, it would be much appreciated. rolleyes.gif
Go to the top of the page
 
+Quote Post
DetlevD
post Dec 3 2016, 12:59
Post #2


Member


Group: Full Members
Posts: 6729
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.85



QUOTE (PDWhite @ Dec 2 2016, 20:53) *
I am attempting to create an export script that uses variables to sum up %length% values ...

For examples see there ...
https://forums.mp3tag.de/index.php?showtopic=11446
https://forums.mp3tag.de/index.php?showtopi...ost&p=54183
https://forums.mp3tag.de/index.php?showtopic=13656

DD.20161203.1300.CET


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
PDWhite
post Dec 3 2016, 19:51
Post #3


Member


Group: Members
Posts: 4
Joined: 27-November 16
From: Houston, Texas USA
Member No.: 22760
Mp3tag Version: 2.80



Thank you for your reply.

Before adding this thread to the forum, I had searched and found the links referenced in your reply. Unfortunately that is not what I've set out to do.

It is not my purpose to find the total playing time of my listed files, but rather to crate a running total.

I.E., Tune #1 length is 90 seconds, Running total is 90 seconds.
Tune #2 length is 208 seconds. Running total is 298 seconds.
Tune #3 length is 104 seconds. Running total is 402 seconds, etc.

I am trying to add the length of the current tune in the loop to the time total of the preceding tunes.

The running total will only show the full running time when the entire loop is completed.

I tried adding $num(%_length_seconds%,5), to a variable named RTTL, which was created by $put(RTTL,($num(%_length_seconds%,5)) on the first time through the loop.

So far, I have been unable to add a number to an existing (numeric) variable. I can $add two 'numbers' and $put them to a variable, but not add a number to value of a numeric variable.

Since the $get(RTTL) value from the first pass returns the contents in parentheses, I am assuming that it is numeric and that I can use it as a number and add its value in a $add statement. But it just won't work.

There does not appear to be any explicit functionality for casting a user variable to string or a string to numeric.

If there is any syntactical manipulation that makes it possible to add a numeric value to the value of an existing user variable or put the sum into a second user variable, I would like to know it.


Thank you. smile.gif
Go to the top of the page
 
+Quote Post
ryerman
post Dec 3 2016, 21:48
Post #4


Member


Group: Full Members
Posts: 242
Joined: 16-August 09
From: Canada
Member No.: 10731
Mp3tag Version: 2.85



QUOTE (PDWhite @ Dec 3 2016, 13:51) *
It is not my purpose to find the total playing time of my listed files, but rather to crate a running total.

I.E., Tune #1 length is 90 seconds, Running total is 90 seconds.
Tune #2 length is 208 seconds. Running total is 298 seconds.
Tune #3 length is 104 seconds. Running total is 402 seconds, etc.

I am trying to add the length of the current tune in the loop to the time total of the preceding tunes.

Try this:
CODE
$loop(%track%)$puts(RunTotal,$add(%_length_seconds%,$get(RunTotal)))%_length_seconds%*$get(RunTotal)*
$loopend()


--------------------
Windows 10 Home, 64 bit
Go to the top of the page
 
+Quote Post
PDWhite
post Dec 4 2016, 01:11
Post #5


Member


Group: Members
Posts: 4
Joined: 27-November 16
From: Houston, Texas USA
Member No.: 22760
Mp3tag Version: 2.80



Thank you ryerman. I will try as you suggest.

But this raises another question. Why isn't this stuff, (namely the use of '*') documented somewhere? Or am I missing something?

Is this an implicit part of MP3TAG scripting, or is the scripting used by MP3TAG a subset of another scripting language?

If it is, please let me know what language it is based on.so I can refer to it.

Again, thank you for your reply. I hope it resolves the issue. smile.gif
Go to the top of the page
 
+Quote Post
ryerman
post Dec 4 2016, 04:09
Post #6


Member


Group: Full Members
Posts: 242
Joined: 16-August 09
From: Canada
Member No.: 10731
Mp3tag Version: 2.85



QUOTE (PDWhite @ Dec 3 2016, 19:11) *
But this raises another question. Why isn't this stuff, (namely the use of '*') documented somewhere? Or am I missing something?

"*" has no special meaning here. It did nothing to manipulate data. It is not a wild-card.
I used it merely as a separator for the output, which you will see if you try the export script.
It could have been any other non-special character.

Use the "Support" button at the top of the forum to find lots of documentation.
eg. http://help.mp3tag.de/main_scripting.html


--------------------
Windows 10 Home, 64 bit
Go to the top of the page
 
+Quote Post
PDWhite
post Dec 4 2016, 21:33
Post #7


Member


Group: Members
Posts: 4
Joined: 27-November 16
From: Houston, Texas USA
Member No.: 22760
Mp3tag Version: 2.80



Ryerman,

Thank you again. Your code works fine. It is very similar to what I was doing, using the Scripting References Pages as a guide.

The main difference I can see is that I was using $num() to convert the output of %_length_seconds% to a numeric value, assuming (incorrectly) that the output would be a string.

You help is greatly appreciated. Thank you!
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 16th December 2017 - 08:26