[Logo] Jaikoz and SongKong Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Introducing Javascript functions to simplify filename masks  XML
Forum Index -> General
Author Message
paultaylor

Pro
[Avatar]

Joined: 21/08/2006 09:21:27
Messages: 7296
Offline

Consider this simple mask

Code:
 (album.length>0 ? album + '-':'') + (trackno.length>0 ? trackno + '-':'')  + (title.length>0 ? title:'')
 


Although its fairly clear what it is doing. its very fiddly and long winded and easy to make a mistake. Unfortunately as a number of you have commented the Javascript is not as easy to understand as the old syntax, I traded this for the power the Javascript notation gives us.

However recently discovered there is nothing to stop you defining functions within your filename mask so the above can be replaced by

Code:
 function ifnotempty(value,sep){
     return value != undefined && value.length > 0 ? value + sep : '';
 }
 ifnotempty(album,'-')+ ifnotempty(trackno,'-') + ifnotempty(title,'') 
 


As you can now see the complexity is put into the function once, then the resultant mask can be much more concise.

In future versions of Jaikoz Im going to add the ability to create and store custom javascript functions with a name to make this even easier, but hopefully in the meantime the use of functions should make creating masks simpler.

thanks Paul (Administrator)
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.6 © JForum Team