I'm familiar with how case statements work, I'm looking for some help on how to select the proper case statement based solely on the artists first letter. This is being used for a MySQL database being imported via csv.
So it would be something like:
if (%artist% == 'A')
then SQL foo = SQL A directory
else
if (%artist% == 'B')
then SQL foo = SQL B directory
.
.
if (%artist% == 'Z')
then SQL foo = SQL Z directory
if (%artist% == '0-9')
then SQL foo = SQL NUMBER directory
This will be done in the export option that I have to build. I have full control of the csv aspect, I'm just trying to figure out how to do case selection or do I have to do a long winded if/else/elseif/elseif type thing
Can someone point me to a previous example or give me a short hand script of how this would look in the export routine.
if (first character is between 0 and 9) then
return: SQL foo = SQL NUMBER directory
else
return: SQL foo = SQL + (first character) + directory
endif
The 'between' is done with the $and, the $geql (greater than or equal) and the $leql (less than or equal) functions. If the character is greater than or equal 0 AND it's less than or equal 9, then it's a digit.
The A through Z part is simply the ELSE part of the if then else, which inserts the first character into the SQL string.
Thanks for the SQL info, I'll bookmark those for future use. My input at the core is csv import, but the HTML is bringing that into a MySQL database for web application. So I don't really need to have true SQL generation.
I'm using this for an online "wishlist" system for a backend. They can search by artist and then create an online playlist.
I'm looking at the code now, I understand how it works and again, it seems the simplistic logic just clouded my thought......easy when I saw the examples.
I'm bumping into syntax errors and I thought I had a good handle on it, not sure what I'm doing wrong. I've tried a few variants like:
($if($and($geql($left(%artist%,1),'0'),$leql($left(%artist%,1),'9'))),ABP Alphabetical Music List/NUMBERS, NULL)
($if($and($geql($left(%artist%,1),'0'),$leql($left(%artist%,1),'9'))),ABP Alphabetical Music List NUMBERS, NULL)
($if($and($geql($left(%artist%,1),'0'),$leql($left(%artist%,1),'9'))),ABP Alphabetical Music List/NUMBERS,)
But the output keeps giving me:
invalid $if syntax
I want to do this for the numbers and then a-z, so I believe leaving the false part of the statement blank should leave the output alone and then test for the remaining 26 cases. I need the final output to wind up as > ABP Alphabetical Music List/NUMBERS or ABP Alphabetical Music List/A or ABP Alphabetical Music List/B............etc
I thought it might need an escape char for the \ but even removing that isn't work. I'm not sure what the issue is. I'm sure its something stupid on my end. Thoughts?
It is not clear to me what you want to achieve.
Do you want to use Mp3tag to create a report file, hm ... maybe yes, and the output lines should be sorted by groups, depending on the first letter of the artist name?
So you have to concentrate your work to develop a $loop() ... $loopend() construct, which fits to your need.
Doing another approach you can create a temporary tag-field within each media file, which holds the sort criterium for the report loop, and what can be removed afterwards if needed.
Action: Format value
Field: TMP_SORT
Format string: $if($isdigit($left(%ARTIST%,1)),'0',$upper($left(%ARTIST%,1)))
The export loop expression can be rather simple like ...