/* Source for MORE.COM, a text file reader intended for use with SpartaDOS  */#define CR  13          /* ASCII carriage return */#define ACR 155         /* ATASCII carriage return */#define isvalid(c) ((c >= ' ' && c <= '|') || (c >= ' ' && c <= 'ό'))/* macro for this characters that should be displayed */int c, col, row, iocb, comtab, pos;char k;char *fname = "                             ", *ext = "TXT";main()$(  char *df;     /* temporary variable to hold filename */  df = fname;   /* initialize df to spaces */  comtab = dpeek(10); /* find start of Spartados table */  poke(82, 0);  iocb = col = row = 0;  c = ' ';  if (peek(comtab) == 76 && peek(comtab + 3) == 76) /* if these are here, we                                                       are probably in Spartados */    iocb = getcomline(); /* use Spartados routine to get filename */  if (iocb < 1) $( /* must get filename manually */    fname = df; /* reset pointer */    iocb = getread(fname, ext); /* get filename manually */  $)  printf("\f"); /* initial clear screen */  while (c >= 0) $( /* c < 0 indicates an error */    while ((c = cgetc(iocb)) >= 0 && row < 23) $( /* get characters */      if isvalid(c) $( /* should we display it? */        printf("%c", c); /* print the character! */        col++; /* advance the column counter */      $)      if (col == 40 || c == CR || c == ACR) $( /* a special case? */        if (c == CR || c == ACR)          printf("\n"); /* carriage return of some kind, so print one! */        col = 0; /* reset column counter */        row++; /* advance row counter */      $)    $)    if (row == 23) $(      row = 0; /* time to hold screen display */      while ((k = getkey()) != 'q' && k != 'Q' && k != ' '); /* wait for                                                                keypress */      if (k == 'q' || k == 'Q') $( /* quit displaying file */        close(iocb);        printf("\n\nMORE.COM (c)1987 Bill Sheppard FREEWARE!\n");/* What can I say - I like being famous! */        exit(); /* back to DOS */      $)      else /* not a 'q', so display the next screen */        if isvalid(c)          printf("\f%c", c); /* clear screen, display last character read */        else          printf("\f"); /* clear screen */    $)  $)  close(iocb); /* All done! */  printf("\n\nMORE.COM (c)1987 Bill Sheppard FREEWARE!\n");/* Give me credit if the file ends normally! */  getkey(); /* wait for final keypress */$)getread(s, ext) /* read a filename from the keyboard */char *s, *ext;$(  int iocb;  char ds[28]; /* buffer to hold filename with path */  getname(s); /* get the name */  iocb = 0;  while(iocb < 1) $( /* iocb < 1 indicates error opening file *//* This next section does the equivalent of the 'normalize()' routine *//* in CC8/ACEC which has a bug dealing with filenames > 11 characters */    if (sfind(s, ".") == -1) /* look for '.' indicating extension was typed */      strcat(s, ".TXT"); /* Append '.txt' if no extension was input */    if (sfind(s, ":") == -1) $( /* look for ':' indicating drive # was typed */      strcpy(ds, "D4:"); /* Add default drive if none specified */      strcat(ds, s);      s = ds; /* put it all together */    $)    iocb = copen(s, 'r'); /* open the file */    if (iocb < 1) $( /* file couldn't be opened, so try again */      printf("Can't open %s\n", s);      closeall();      getname(s);    $)  $)  return iocb;$)getname(s) /* actually get filename from keyboard */char *s;$(  printf("Please enter filename: ");  gets(s);  if (!s[0]) $( /* nothing typed, so exit */    closeall();    exit(); /* I won't make you see the credit line if you quit here! */  $)$)getcomline() /* access Spartados routine to get filename */$(  char *dd;  usr(comtab + 3); /* SD routine to read command line */  dd = fname = comtab + 33; /* SD buffer location *//* Filename stored in SD buffer will end with CR - we need to change this *//* to a \0 null character. */  while(*fname != '\n')    fname++;  if (fname == dd + 3) /* this indicates no filename was entered */    return(0);  else $(    *fname = '\0';    fname = dd;/* Again, do normalizing of filename */    if (sfind(fname, ".") == -1) /* look for '.' indicating extension was typed */      strcat(fname, ".TXT"); /* Append '.txt' if no extension was input */    iocb = copen(fname, 'r');    if (iocb < 1) $(      printf("Can't open %s\n", fname);      closeall();    $)    return(iocb);  $)$)