Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge: International version of PRINT USING
#1
It just dawned on me that the PRINT USING statement is designed only for USA formatted numbers; that is, using the decimal point to delimit fractional values, and commas to separate thousands. Also, the statement only uses the dollar sign.

Other countries use a comma instead of a decimal point to delimit fractional values, periods (decimal points) to separate thousands, and their own currency symbol instead of the dollar sign.

CHALLENGE: Write a replacement function, sub-program, or subroutine that allows for specifying:

1) The delimiter (comma or decimal point) for fractional values. Example: The number 123.45 in the USA is printed as 123.45 and in other countries (like Spain) as 123,45

2) The separator character for thousands.
Example: The number 12345 is printed as 12,345 in the USA and in other countries as 12.345

3) The currency symbol to use. Example: $ or €

FORMATTING CHARACTERS: The formatstring for the PRINT USING specifies 12 formatting characters for formatting strings and numbers (check your manual). For this challenge we will only use the following formatting characters for numbers only:
(#) for each digit position.
(Specified delimiter for fractional values) decimal pt or comma.
(+) causes sign of the number to be printed before the number.
(-) causes negative number to be printed with a trailing minus sign.
(**) Asterisk protection: causes leading spaces in numeric field to be filled with asterisks.
($$) Floating dollar sign: we will continue to use $$ to specify this feature, but it should actually print the currency symbol defined.
(**$) Floating dollar sign with asterisk protection. A combination of the two above.
(specified separator character for thousands) comma or decimal pt.

PLEASE: when you submit the code for your solutions, please preface the code with a brief explanation of your method or idea for the solution.

NOTE: There are several ways of doing this, some relatively simple, others very complicated. For the most part, I will not get into your code, I'll just compile it and test some results. I'll try to keep up with your entries.

I will request that the winner's code be posted in the tutorials section.
*****
Reply
#2
Hey some of you guys outside of the USA, I'm sure you must have encountered incompatibility problems with the PRINT USING statement in your country. Tell us about how you handled this problem. I can't believe you have a local-country, translated version of QB or QuickBASIC.
*****
Reply
#3
Moneo,

What character is supposed to be used for the Euro? We're using a program that predates it by a couple of decades. CHR$(238) looks close.
hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Reply
#4
SCM,

That's a really good question. I really don't know because I have a new keyboard which comes with the Euro symbol. That's how I printed it in point (3) above.

The symbol displays fine in Windows, but if you transfer the character to a text file to look at it with a hex editor in MSDOS, it converts the character to a capital French C, the one with the hook at the bottom.

Is there such a thing as a hex editor that runs in Windows?
*****
Reply
#5
My favorite is Hex Workshop
Reply
#6
Thanks, Plasma, checked out the Hex Workshop site and it sounds great except for the $50 price. A bit much for the once in a blue moon that I might need it. But thanks anyway.

BTW, if you have it, please tell SCM what the hex (or decimal) character code is for the following Euro symbol: €
*****
Reply
#7
The Euro is D5h (213) on codepage 858.
Reply
#8
It's possible to modify characters in the ascii table... maybe thats an option to make the euro available.
onathan Simpson
Reply
#9
Hey you guys outside the USA where you use a comma instead of a decimal point.

Have you ever had problems with PRINT USING? Have any of you written any check printing, invoice or statement printing programs in your country and tried to use PRINT USING?

If this was not a problem, tell me how you did it.
*****
Reply
#10
I find it an interesting challenge, and I would enter if I had the time. It involves parsing and using FSMs, two things that I love... But I have 0 time Sad

As for having needed it, I have never. For business applications I've always used Visual Basic, in every assignment or job I've had running QB was a problem, and using Visual Basic is so easy that it hurts Tongue

Seriously, I think I never wrote "PRINT USING" in a proggie. In QB all I've done is games, scripting systems, DOS utils and interpreters.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)