Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : ADVANCED.ZIP
Filename : TRANSLAT.PRG

 
Output of file : TRANSLAT.PRG contained in archive : ADVANCED.ZIP
*********************************** Translate.PRG
*--------- Convert a number to English Equivalent.
* Make English variable PUBLIC in calling program.
PROCEDURE Translate
PARAMETERS Amount,English

*---------- Set up memory variables.
Counter = 1
Start = 1
String = STR(Amount,9,2)
English = " "

*-------- Loop through thousands and hundreds.
DO WHILE Counter < 3

*------ Split out hundreds, tens, and ones.
Chunk = SUBSTR(String,Start,3)
Hun = SUBSTR(Chunk,1,1)
Ten = SUBSTR(Chunk,2,2)
One = SUBSTR(Chunk,3,1)

*------ Handle hundreds portion.
IF VAL(Chunk) > 99
English = English + U&Hun + ' HUNDRED '
ENDIF (chunk > 99)

*------ Handle second 2 digits.
T = VAL(Ten)
IF T > 0

DO CASE
* Case 1: Handle even tens and teens.
CASE (INT(T/10.0)=T/10.0).OR.(T>9.AND.T<20)
English = English + U&Ten

* Case 2: Handle greater than 10,
* but not evenly divisible.
CASE T > 9 .AND. (INT(T/10.0)#T/10.0)
Ten = SUBSTR(Ten,1,1) +'0'
English = English + U&Ten+' '+U&One

* Case 3: Handle less than 10.
CASE T < 10
English = English + U&One

ENDCASE

ENDIF (T > 0)

*-- Add "Thousand" if necessary.
IF Amount > 999.99 .AND. Counter = 1
English = English +' THOUSAND '
ENDIF (need to add "thousand")

*-- Prepare for pass through hundreds.
Start = 4
Counter = Counter + 1

ENDDO (while counter < 3)

*----- Tack on cents.
IF INT(Amount) > 0
English = English + " AND "
ENDIF

English = English + SUBSTR(String,8,2)+"/100"

*-------- End Procedure.
RETURN


  3 Responses to “Category : Dbase (Clipper, FoxBase, etc) Languages Source Code
Archive   : ADVANCED.ZIP
Filename : TRANSLAT.PRG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/