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


Messages In This Thread
Challenge: International version of PRINT USING - by Moneo - 05-10-2004, 12:45 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)