Category : Paradox DBMS
Archive   : DLIST.ZIP
Filename : DLIST.C

 
Output of file : DLIST.C contained in archive : DLIST.ZIP
#include
#include
#include
#include
#include

struct ffblk ffblk;
int done;
int dircount;
int i,j;
typedef struct listtype
{
char dirname[12];
};
struct listtype * dirlist;
char tempstring[80];
char istring[6];
FILE *dfile;

void main ()
{

/* find out how much memory to ask for */

dircount = 0;
done = findfirst("*.*",&ffblk,FA_DIREC);
while (! done)
{
if ((ffblk.ff_attrib & FA_DIREC) && strcmp(ffblk.ff_name,"."))
dircount++;
done = findnext(&ffblk);
}
/* ask for it */

dirlist = (struct listtype *) calloc(dircount,sizeof(struct listtype));

/* if we can't get it, do a rude dump (no error message!) */

if (dirlist == NULL) exit(1);

/* get the directories and put them somewhere to sort */

i = 0;
done = findfirst("*.*",&ffblk,FA_DIREC);
while (! done)
{
if (ffblk.ff_attrib & FA_DIREC)
{
/* Substitute the word PARENT for the .. that comes in, if need be */

if (strncmp(ffblk.ff_name,"..\0",2)==0)
{
strcpy(dirlist[i].dirname,"PARENT\0");
i++;
}

/* don't include current dir as a choice */

if ( strncmp(ffblk.ff_name,".\0",1) && strncmp(ffblk.ff_name,"..\0",2))
{
strcpy(dirlist[i].dirname,ffblk.ff_name);
i++;
}
}
done = findnext(&ffblk);
}

/* sort the list */

qsort(dirlist,dircount,sizeof(dirlist[0]),strcmp);

/* now write the script */

dfile = fopen("chgdir.sc","w+t");

/* declare arrays the size of the number of dirs */

fputs("array dirs[\0",dfile);
itoa(dircount,istring,10);
fputs(istring,dfile);
fputs("]\n",dfile);
fputs("array dexp[\0",dfile);
itoa(dircount,istring,10);
fputs(istring,dfile);
fputs("]\n\n",dfile);

/* set the arrays equal to the dir names and a help message with dir name */

for(i=0;i {
strcpy(tempstring,"dirs[\0");
itoa(i+1,istring,10);
strcat(tempstring,istring);
strcat(tempstring,"] = \0");
istring[0] = 0x22;
istring[1] = 0;
strcat(tempstring,istring);
fputs(tempstring,dfile);

/*
you could replace the next line with a some code that would put
the full path (from the root) in its place (use double \\s) to
create scripts that run from any directory. If your paths are
pretty long, though, I'd make the changes below where it actually
sets the directory, not here where it would be too big for a menu
*/

fputs(dirlist[i].dirname,dfile);

strcpy(tempstring,istring);
strcat(tempstring,"\n\0");
fputs(tempstring,dfile);
strcpy(tempstring,"dexp[\0");
itoa(i+1,istring,10);
strcat(tempstring,istring);
strcat(tempstring,"] = \0");
istring[0] = 0x22;
istring[1] = 0;
strcat(tempstring,istring);
strcat(tempstring,"Change to the directory \0");
strcat(tempstring,dirlist[i].dirname);
strcat(tempstring,istring);
strcat(tempstring,"\n\0");
fputs(tempstring,dfile);
}

/* write the code that puts the menu up, and gets the choice */

fputs("Showarray \n",dfile);
fputs(" dirs dexp \n",dfile);
fputs(" default dirs[1] \n",dfile);
fputs("to dirchoice\n",dfile);

/* let the user press ESC to exit the menu without changing dir */

fputs("if dirchoice = ",dfile);
fputc(0x22,dfile);
fputs("Esc",dfile);
fputc(0x22,dfile);
fputs(" then \n",dfile);
fputs(" return\n",dfile);
fputs("endif\n",dfile);

/*
if the choice is parent, then get the current full path, chop off
where we are, and leave the path to the parent. Add an extra \ for
Paradox's sake
*/

fputs("if dirchoice = ",dfile);
fputc(0x22,dfile);
fputs("PARENT",dfile);
fputc(0x22,dfile);
fputs(" then \n",dfile);
fputs(" setdir(",dfile);
fputc(0x22,dfile);
getcwd(tempstring,78);
*(strrchr(tempstring,'\\')+1) = 0;
i = 0;
while (tempstring[i])
{
if (tempstring[i] == '\\')
{
fputc('\\',dfile);
fputc('\\',dfile);
}
else
fputc(tempstring[i],dfile);
i++;
}
fputc(0x22,dfile);
fputs(")\n",dfile);
fputs("else\n",dfile);
fputs(" setdir(dirchoice)\n",dfile);
fputs("endif\n\n",dfile);
fclose(dfile);
}


  3 Responses to “Category : Paradox DBMS
Archive   : DLIST.ZIP
Filename : DLIST.C

  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/