Support and General Use > Theming and Appearance Customization

[App] Rockbox Font Convertor [Windows]

<< < (4/14) > >>

bascule:
Well, JustJohnny, that's certainly more elegant than mine. I've never used SHIFT before, but reading up on it I see how it works.

Neat!

I think I'll leave it for the OP to decide...

JustJohnny:
Hi Bascule,

Yes, shift worked out well. I wanted  to use some type of while loop to go through the list of the arguments, but didn't find any convenient way to do this. Found the shift command after googling for "windows+batch+reference" and realized I could make my own while loop with the shift and the goto command. The hardest part was finding a way to check if the last thing the FONTSIZE was set to was an integer.

bascule:

--- Quote from: JustJohnny on February 25, 2007, 09:11:42 PM ---The hardest part was finding a way to check if the last thing the FONTSIZE was set to was an integer.

--- End quote ---

So how did you do it?

I don't understand (and can't find on the intarweb) what the "+" (plus) sign means in these lines:

--- Quote ---IF %FONTSIZE% NEQ +%FONTSIZE% (SET FONTFILE=%FONTFILE% %FONTSIZE%)
IF %FONTSIZE% NEQ +%FONTSIZE% (SET FONTSIZE=%DEFAULTFONTSIZE%)
--- End quote ---

For my batch file, I used:


--- Quote ---if %2 LEQ a (goto 2-CaseSizeSet) else (goto 2-CaseNoSize)
--- End quote ---

which returns TRUE if %2 is a numeric value, because all numbers are mathematically less than the alphabetic character 'a'.

bascule:
OK, well here we go!

Taking the simplicity of JustJohnny's use of shift and changing the syntax back-to-front to:

makefont [fontsize] filename

in order to make the initial assessment of whether the fontsize option has been included or not, I've elegantly (IMHO) reduced the batch file to something I'm happy with (attached).

Unfortunately, whilst looking for how to write the syntax correctly I found/re-discovered/remembered that the simple answer all along to the whole problem would have been to do this:

makefont "a really long font name.ttf" 14

and it would always appear as only two parameters %1 and %2.

D'oh!

[attachment deleted by admin, too old]

JustJohnny:

--- Quote from: bascule on February 26, 2007, 09:33:21 AM ---OK, well here we go!

Taking the simplicity of JustJohnny's use of shift and changing the syntax back-to-front to:

makefont [fontsize] filename

in order to make the initial assessment of whether the fontsize option has been included or not, I've elegantly (IMHO) reduced the batch file to something I'm happy with (attached).


--- End quote ---

Bascule, I see your batch foo is stronger than mine, and using the traditional kung-fu action movie trick of using my powers against me have come up with a truly beautiful solution--even giving the command structure a more typical usage pattern:  Command [options] < object of the command >.

I bow before your most elegant solution  :)

I wonder if this takes care of any "drag and drop" problems?

Also I liked in your previous version how you pointed out where to change the default font size.  Perhaps adding a note in your rem statement about that, or creating a DEFAULTFONTSIZE variable which is declared at the top for easy access.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version