home *** CD-ROM | disk | FTP | other *** search
- #include <SetUpA4.h>
-
- static char unites[10][8] = { "nul","een","twee","drie","vier","vijf","zes","zeven","acht","negen" } ;
- static char dizaines[10][14] = { "","tien","twintig","dertig","veertig","vijftig","zestig","zeventig","tachtig","negentig" } ;
- static char multiples[4][9] = { "honderd","duizend","miljoen" ,"miliard"} ;
- static char special[10][10] = { "tien","elf","twaalf","dertien","veertien","vijftien","zestien","zeventien","achtien","negentien"} ;
-
- char *strcpy(char *s1,char *s2) ;
- char *strcat(char *s1,char *s2) ;
- void reverse(char *s) ;
- short strlen(char *s) ;
- short dutch(char *temp,char *tmpresult,short n) ;
-
- pascal void Debugger(void)
- = 0xA9FF;
-
- pascal void main(char *text,char * result)
- {
- char thestring[20],temp[4],tmpresult[256];
- short i,j,l,res ;
- short plurial ;
-
- RememberA0() ;
- SetUpA4() ;
- text[12] = 0 ; /* max = 999 999 999 999 */
- result[0] = '\0' ;
- (void)strcpy(thestring,text) ;
- if( strlen(thestring) != 0 )
- {
- while (thestring[0] == '0')
- for (i=0;thestring[i]!=0;thestring[i]=thestring[i+1],i++) ;
- plurial = 0 ;
- if ( (l = strlen(thestring)) )
- {
- reverse(thestring) ;
- if (l < 12)
- {
- for ( i=l ; i<12 ; i++ )
- thestring[i] = '0' ;
- thestring[12] = 0 ;
- }
- for ( i=3 ; i>=0 ; i--)
- {
- for ( j=3*i ; j<3*(i+1) ; j++)
- temp[j-3*i] = thestring[j] ;
- temp[3] = 0 ;
- tmpresult[0] = 0 ;
- res = dutch(temp,tmpresult,i) ;
- if ( (res > 1) || ((res == 1) && (i != 0)) )
- plurial = 1 ;
- strcat(result,tmpresult) ;
- }
- }
- else
- strcpy(result,unites[0]) ;
- }
- RestoreA4() ;
- }
-
- short dutch(char *temp,char *tmpresult,short n)
- {
- register int res,x,y,z;
-
- reverse(temp);
- x=temp[0]-'0';
- y=temp[1]-'0';
- z=temp[2]-'0';
- res=((x*10)+y)*10+z;
- if(res!=0)
- {
- if((x==0)&&(y==0)&&(z==0))
- return;
- if(x>1)
- {
- strcat(tmpresult," ");
- strcat(tmpresult,unites[x]);
- strcat(tmpresult,multiples[0]);
- }
- if(x==1)
- {
- strcat(tmpresult," ");
- strcat(tmpresult,multiples[0]);
- }
- if(y==0)
- {
- if(z>1)
- {
- strcat(tmpresult," ");
- strcat(tmpresult,unites[z]);
- }
- else
- if(z==1)
- if((n==1)&&(x==0))
- strcat(tmpresult," ");
- else
- {
- strcat(tmpresult," ");
- strcat(tmpresult,unites[z]);
- }
- }
- else
- {
- if(y==1)
- {
- strcat(tmpresult," ");
- strcat(tmpresult,special[z]);
- }
- else
- {
- if(z==0)
- {
- strcat(tmpresult," ");
- strcat(tmpresult,dizaines[y]);
- }
- else
- {
- strcat(tmpresult," ");
- strcat(tmpresult,unites[z]);
- if((z==2)||z==3)
- strcat(tmpresult,"ën");
- else
- strcat(tmpresult,"en");
- strcat(tmpresult,dizaines[y]);
- }
- }
- }
- if(n)
- {
- if(((x!=0)&&((y!=0)||(z!=0))&&(n==1))||(n>1))
- strcat(tmpresult," ");
- strcat(tmpresult,multiples[n]);
- }
- }
- return(res);
- }
-
-
- char * strcpy(char *s1,char *s2)
- {
- asm {
- movea.l s1,a0 ; A0 = s1
- movea.l s2,a1 ; A1 = s2
- move.l a0,d0 ; D0.L = result
- @1 move.b (a1)+,(a0)+
- bne.s @1
- }
- }
-
-
- char *strcat(char *s1,char *s2)
- {
- asm {
- movea.l s1,a0 ; A0 = s1
- movea.l s2,a1 ; A1 = s2
- move.l a0,d0 ; D0.L = result
- @1 tst.b (a0)+
- bne.s @1
- subq.l #1,a0
- @2 move.b (a1)+,(a0)+
- bne.s @2
- }
- }
-
- short strlen(char *s)
- {
- asm {
- moveq #-1,d0 ; D0.L = result
- movea.l s,a0 ; A0 = s
- @1 addq.l #1,d0
- tst.b (a0)+
- bne.s @1
- }
- }
-
- void reverse(char *s)
- {
- register short i,j ;
- register char c ;
-
- for(i=0,j=strlen(s)-1;i<j;i++,j--)
- {
- c = s[j] ;
- s[j] = s[i] ;
- s[i] = c ;
- }
- }
-
-