10 // Verbaal - takes a number and writes out the Dutch textual representation 20 // (c) Copyright 1987-2004 Jos Visser 30 // Licensed for use under the GNU General Public License 40 // 50 WHILE NOT(EOD) DO 60 READ a 70 PRINT a;" ";verbaal$(a) 80 ENDWHILE 90 // 100 DATA 1, 12, 34, 112, 1009, 1234567890 110 // 120 FUNC verbaal$(getal#) CLOSED 130 // 140 // ************************************ 150 // ** FUNC Verbaal$ ( Integer ) ** 160 // ************************************ 170 // 180 // Geschreven door Jos Visser, 25-06-1987 190 // Aangepast voor PDCOMAL, 10-9-92 200 // 210 // 220 // Functie : 230 // Deze functie neemt als parameter een integer getal, 240 // positief danwel negatief, en geeft een string terug 250 // die weergeeft hoe dat getal op zijn Nederlands 260 // geschreven kan worden. 270 // 280 // Parameters in : 290 // Integer getal 300 // 310 // Parameters uit : 320 // String, maximaal 132 karakters lang 330 // 340 // Packages ed. : 350 // Geen 360 // 370 PROC skipspaces(REF a$) CLOSED 380 IF a$<>"" THEN 390 WHILE a$(LEN(a$):LEN(a$))=" " DO a$:=a$(1:LEN(a$)-1) 400 ENDIF 410 ENDPROC 420 // 430 FUNC cijfer$(nr#) CLOSED 440 DIM a$ OF 5 450 a$:="nul een twee drie vier vijf zes zevenacht negentien "(1+nr#*5:5+nr#*5) 460 skipspaces(a$) 470 RETURN a$ 480 ENDFUNC 490 // 500 FUNC t'11'19$(nr#) CLOSED 510 DIM a$ OF 10 520 a$:="tien elf twaalf dertien veertien vijftien zestien zeventienachtien negentien"(1+(nr#-10)*9:9+(nr#-10)*9) 530 skipspaces(a$) 540 RETURN a$ 550 ENDFUNC 560 // 570 FUNC tiental$(nr#) CLOSED 580 DIM a$ OF 10 590 nr#:=nr# DIV 10 600 a$:="twintig dertig veertig vijftig zestig zeventigtachtig negentig"(1+(nr#-2)*8:8+(nr#-2)*8) 610 skipspaces(a$) 620 RETURN a$ 630 ENDFUNC 640 // 650 FUNC duizend$(nr#) CLOSED 660 honderd#:=nr# DIV 100 670 rest#:=nr# MOD 100 680 IF honderd#>1 THEN 690 result$:=cijfer$(honderd#)+"honderd" 700 ELIF honderd#=1 710 result$:="honderd" 720 ELSE 730 result$:="" 740 ENDIF 750 IF rest#<=10 THEN 760 IF rest#<>0 OR honderd#=0 THEN result$:+cijfer$(rest#) 770 ELIF rest#<20 780 result$:+t'11'19$(rest#) 790 ELSE 800 IF rest# MOD 10<>0 THEN result$:=result$+cijfer$(rest# MOD 10)+"en" 810 IF rest# DIV 10>0 THEN result$:+tiental$(rest#) 820 ENDIF 830 RETURN result$ 840 ENDFUNC 850 // 860 DIM result$ OF 132, subresult$ OF 40 870 result$:="" 880 IF getal#<0 THEN 890 negatief#:=TRUE 900 getal#:=-getal# 910 ELSE 920 result$:="" 930 negatief#:=FALSE 940 ENDIF 950 FOR macht#:=9 DOWNTO 0 STEP 3 DO 960 subgetal#:=getal# DIV 10^macht# 970 getal#:=getal# MOD 10^macht# 980 IF subgetal#>0 OR (macht#=0 AND result$="") THEN 990 subresult$:=duizend$(subgetal#) 1000 IF macht#<>3 OR subgetal#<>1 THEN 1010 result$:=result$+", "+subresult$ 1020 ELSE 1030 IF result$="" THEN result$:=" " 1040 ENDIF 1050 CASE macht# OF 1060 WHEN 9 1070 result$:+" miljard " 1080 WHEN 6 1090 result$:+" miljoen " 1100 WHEN 3 1110 result$:+"duizend " 1120 OTHERWISE 1130 NULL 1140 ENDCASE 1150 ENDIF 1160 skipspaces(result$) 1170 ENDFOR 1180 result$:=result$(3:) 1190 IF negatief# THEN result$:="min "+result$ 1200 RETURN result$ 1210 ENDFUNC 1220 //