Pascal to C (and vice versa)

Sean Malloy malloy at nprdc.arpa
Fri Oct 27 00:38:50 AEST 1989


In article <6684 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
>For what it's worth, I've never seen !set of char! used in a Pascal program,
>out of the old Berkeley pi/px compiler, UCSD, a couple of micro cross-
>compilers, and Turbo (which is to Pascal as Ratfor is to Fortran-77). I
>know that at least one of the micro systems didn't allow it (probably both,
>they were from the same vendor), and neither did UCSD.

Here's the INTERFACE section of the MENUS unit written in UCSD Pascal that
we used all through the software we developed for the Semantic Network
Training System (a collection of programs running on TERAK micros that
would drill users on a database of information to be memorized). Note
the use of 'SET OF Char' in the definition of the MenuVarRec type. If
we'd known that UCSD Pascal didn't allow 'SET OF Char', we probably
would have written it some other way. Funny that our UCSD Pascal
compiler didn't seem to complain about it, though.

--------------------------------------------------------------------------------
{===============================================}
{  Unit:        Menus                           }
{  Author:      Steve Putz                      }
{  Filename:    MENUS;L.TEXT                    }
{  Created:     13-Feb-80                       }
{  Last Update: 13-Jul-82  [SRM]                }
{  Description: see MENUS.DOC.TEXT              }
{  Cleaned appearance; use new MENUS.CHARSET    }
{===============================================}
{$S+}

UNIT Menus;

INTERFACE

  { Menus unit  17-Sep-81 [MoveChars Version] }
  
  CONST
    MenuLines = 100;       { maximum number of items in a ListMenu }
  
  TYPE
    MenuStr  = ^String;
    
    MenuRecord =
          RECORD
            X, Y    : Integer;          { char screen position of top corner }
            width, height: Integer;     { width and height of menu frame }
            topLine : Integer;          { index of first displayed item }
            curItem : Integer;          { current item }
            len     : Integer;          { number of items }
            title   : String;           { displayed above menu }
            list    : ARRAY[1..MenuLines] OF MenuStr;
          END;
  
    MenuVarRec =
        RECORD          { these chars mean the following in MenuUserSel-- }
          SelChars,     { "(de)select this item"      [SELECT] }
          EscChars      { "leave MenuUserSel"  SelChars + [ESC] }
                    : SET OF Char;      { (values may be changed by user) }
        END;
  
  VAR
    MenuVars : ^MenuVarRec;
    
  
  PROCEDURE MenuInit;
    { Initializes the above sets to the default values shown in brackets. }
  
  PROCEDURE MenuNew(VAR menu: MenuRecord; atX,atY,wid,ht: Integer;
                    titleStr: String);
    { Initializes the menu at the given character position
      coordinates and clears the menu. }
  
  PROCEDURE MenuClear(VAR menu: MenuRecord);
    { sets length to zero.  Does not display }
  
  PROCEDURE MenuDisplay(VAR menu: MenuRecord);
    { Displays menu and title. }
  
  PROCEDURE MenuInsert(VAR menu: MenuRecord; text: String; before: Integer);
    { Inserts a line of text into the menu. }
  
  PROCEDURE MenuDelete(VAR menu: MenuRecord; item: Integer);
    { Deletes a line from the menu. }
  
  PROCEDURE MenuContents(VAR menu: MenuRecord; VAR text: String; item: Integer);
    { Returns the text contents of the given line. }
  
  FUNCTION  MenuSelected(VAR menu: MenuRecord; item: Integer) : Boolean;
    { Returns True if the item is selected. }
  
  PROCEDURE MenuReset(VAR menu: MenuRecord);
    { Deselects all selections without redisplaying. }
  
  PROCEDURE MenuComp(VAR menu: MenuRecord; item: Integer);
    { Complements the item, and redisplays that line only, if visible. }
  
  PROCEDURE MenuTopLine(VAR menu: MenuRecord; newTop: Integer);
    { Scrolls the items in the list so item newTop is at the top. }
  
  PROCEDURE MenuScroll(VAR menu: MenuRecord; delta: Integer);
    { Scrolls the menu by delta lines.  Both MenuTopLine and MenuScroll
      cause the menu to be redisplayed. }
  
  FUNCTION  MenuUserSel(VAR menu: MenuRecord) : Char;
    { Allows the user to scroll the menu and select (complement) item(s).
      The last on which the cursor was positioned is in menu.curItem.
      The function returns the character which caused termination, mapped
      to lower case unless EscChars contains upper case. }
  
  
--------------------------------------------------------------------------------
 Sean Malloy                                    | "I am here by the will of
 Navy Personnel Research & Development Center   | the people and will not
 San Diego, CA 92152-6800                       | leave until I get my
 malloy at nprdc.navy.mil                          | raincoat back"



More information about the Comp.lang.c mailing list