Category : C Source Code
Archive   : R50TOASC.ZIP
Filename : R50ASC.C
r50asc.c by Raymond F. Genovese [do whatever you want with it]
Routine demonstrates conversion of radix-50 to ascii
modeled after the FORTRAN function r50asc
[TurboC 2.0 small memory model]
*/
#include
#include
/* we will be making use of the div_t structure and div() function */
/* function prototypes */
char r50toasc(int r50num);
void r50asc(unsigned char n_asc,int *r50_string, char *asc_string);
main()
{
int testr50[]={0x5242,0x26fa,0x0640,0x0df6};
/* testr[] contains radix-50 codes for the strings MFRFIRA and BIN */
char testasc[128];
/* testasc[] is where the converted string will go */
/* MAKE SURE IT'S LARGE ENOUGH! */
printf("\nTest of the RADIX-50 to ASCII conversion function...\n");
r50asc(9,&testr50[0],&testasc[0]);
printf("\nFile Name = %s ",testasc);
r50asc(3,&testr50[3],&testasc[0]);
printf("File Type = %s\n",testasc);
printf("\n[press a key to exit]");
(void)getch();
exit(0);
}
void r50asc(unsigned char n_asc,int *r50_string, char *asc_string)
{
/*
n_asc =number of characters to be converted
*r50_string =pointer to the 2-byte radix-50 integers
*asc_string =pointer to the destination string
NOTES:
*asc_string MUST be at least n_asc + 1 bytes long
The routine will null terminate asc_string
Invalid radix-50 values will be filled with '?'
It is possible that the pointer arithmatic will
require the use of HUGE pointer declarations
*/
int x,r50;
div_t z;
while(n_asc>0){
r50=*r50_string;
/* convert 3 ascii char's from 1 radix-50 int */
/* but will exit before the # of char's requested is exceeded */
z=div(r50,1600);
*asc_string=r50toasc(z.quot);
asc_string++;
if(!(--n_asc))
continue;
z=div(z.rem,40);
*asc_string=r50toasc(z.quot);
asc_string++;
if(!(--n_asc))
continue;
*asc_string=r50toasc(z.rem);
asc_string++;
r50_string++;
if(!(--n_asc))
continue;
}
/* now null the string */
*asc_string=0;
}
char r50toasc(int r50num)
{
/*
converts a radix-50 character to standard ascii
from the DEC standard:
character ascii radix-50
--------------------------------
space 32 0
A-Z 65-90 1-26
$ 36 27
. 46 28
0-9 48-57 30-39
________________________________
any other character becomes ascii 63 (?)
*/
if(r50num==0)
return(32);
else if((r50num>0)&&(r50num<27))
return(r50num+64);
else if(r50num==27)
return(36);
else if(r50num==28)
return(46);
else if((r50num>29)&&(r50num<40))
return(r50num+18);
else return(63);
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/