home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / h / hp11 / Amiga_Code / c_ami / menus < prev   
Encoding:
Text File  |  1992-05-07  |  15.8 KB  |  639 lines

  1. /*-> c.menus */
  2. char message[] =
  3.  "HP11, by David Gay(86-87). You may freely copy & distribute this program.";
  4. char message2[] =
  5.  "Vous pouvez librement copier & distribuer ce programme.";
  6. #include "exec/types.h"
  7. #include "graphics/text.h"
  8. #include "intuition/intuition.h"
  9. #include "workbench/workbench.h"
  10. #include "workbench/startup.h"
  11. #include "libraries/dos.h"
  12. #include "libraries/arpbase.h"
  13. #include "proto/arp.h"
  14. #define NODOS
  15. #include "libraries/arp_pragmas.h"
  16.  
  17. #include "proto/exec.h"
  18. #include "proto/graphics.h"
  19. #include "proto/intuition.h"
  20. #include "proto/icon.h"
  21. #include "proto/dos.h"
  22.  
  23. #include "string.h"
  24. #include "math.h"
  25.  
  26. #include "hp11/hp11.h"
  27. #include "hp11/io.h"
  28. #include "hp11/ins.h"
  29. #include "hp11/amiga/menus.h"
  30. #include "hp11/amiga/internal.h"
  31. #include "hp11/amiga/cbio.h"
  32.  
  33. #define PROJECTWIDTH (75 + COMMWIDTH) /* Width of Project menu options */
  34. #define EDITWIDTH (65 + COMMWIDTH)
  35. #define OPTIONSWIDTH 80
  36. #define DECIMALWIDTH (CHECKWIDTH + 65 + COMMWIDTH)
  37. #define SPEEDWIDTH (CHECKWIDTH + 55)
  38.  
  39. static struct TextAttr topaz9attr = { "topaz.font", 9, 0, 0 }; /* The text font
  40.  desired */
  41. static struct TextFont *topaz9;
  42.  
  43. /* Texts for menu options */
  44. static struct IntuiText hp11text[] = {
  45.    { 2, 1, JAM1, 4, 1, NULL, "New", NULL },
  46.    { 2, 1, JAM1, 4, 1, NULL, "Open", NULL },
  47.    { 2, 1, JAM1, 4, 1, NULL, "Save", NULL },
  48.    { 2, 1, JAM1, 4, 1, NULL, "Save as", NULL },
  49.    { 2, 1, JAM1, 4, 1, NULL, "Print", NULL },
  50.    { 2, 1, JAM1, 4, 1, NULL, "Quit", NULL },
  51.    { 2, 1, JAM1, 4, 1, NULL, "Copy", NULL },
  52.    { 2, 1, JAM1, 4, 1, NULL, "Paste", NULL },
  53.    { 2, 1, JAM1, CHECKWIDTH, 1, NULL, "Radix", NULL },
  54.       { 2, 1, JAM1, CHECKWIDTH, 1, NULL, "Point", NULL },
  55.       { 2, 1, JAM1, CHECKWIDTH, 1, NULL, "Comma", NULL },
  56.    { 2, 1, JAM1, CHECKWIDTH, 1, NULL, "Speed", NULL },
  57.       { 2, 1, JAM1, CHECKWIDTH, 1, NULL, "Slow", NULL },
  58.       { 2, 1, JAM1, CHECKWIDTH, 1, NULL, "Fast", NULL },
  59.    { 2, 1, JAM1, CHECKWIDTH, 1, NULL, "Icons", NULL }
  60. };
  61.  
  62. /* The various menu items */
  63. static struct MenuItem hp11item[] = {
  64.    { &hp11item[1], 0, 0, PROJECTWIDTH, 10, /* New */
  65.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP, 0,
  66.      (APTR)&hp11text[0], NULL, 0, NULL },
  67.  
  68.    { &hp11item[2], 0, 10, PROJECTWIDTH, 10, /* Open */
  69.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] COMMSEQ, 0,
  70.      (APTR)&hp11text[1], NULL, 'O', NULL },
  71.  
  72.    { &hp11item[3], 0, 20, PROJECTWIDTH, 10, /* Save */
  73.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP, 0,
  74.      (APTR)&hp11text[2], NULL, 0, NULL },
  75.  
  76.    { &hp11item[4], 0, 30, PROJECTWIDTH, 10, /* Save as */
  77.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] COMMSEQ,  0,
  78.      (APTR)&hp11text[3], NULL, 'S', NULL },
  79.  
  80.    { &hp11item[5], 0, 40, PROJECTWIDTH, 10, /* Print */
  81.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP, 0,
  82.      (APTR)&hp11text[4], 0, NULL },
  83.  
  84.    { NULL, 0, 50, PROJECTWIDTH, 10, /* Quit */
  85.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP, 0,
  86.      (APTR)&hp11text[5], NULL, 0, NULL },
  87.  
  88.  
  89.    { &hp11item[7], 0, 0, EDITWIDTH, 10, /* Copy */
  90.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] COMMSEQ, 0,
  91.      (APTR)&hp11text[6], NULL, 'C', NULL },
  92.  
  93.    { NULL, 0, 10, EDITWIDTH, 10, /* Paste */
  94.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] COMMSEQ, 0,
  95.      (APTR)&hp11text[7], NULL, 'P', NULL },
  96.  
  97.  
  98.    { &hp11item[11], 0, 0, OPTIONSWIDTH, 10, /* Radix */
  99.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP, 0,
  100.      (APTR)&hp11text[8], NULL, 0, &hp11item[9] },
  101.  
  102.       { &hp11item[10], 50, 9, DECIMALWIDTH, 10, /* Point */
  103.         ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] CHECKIT ] CHECKED ] COMMSEQ, 2,
  104.         (APTR)&hp11text[9], NULL, '.', NULL },
  105.  
  106.       { NULL, 50, 19, DECIMALWIDTH, 10, /* Comma */
  107.         ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] CHECKIT ] COMMSEQ, 1,
  108.         (APTR)&hp11text[10], NULL, ',', NULL },
  109.  
  110.    { &hp11item[14], 0, 10, OPTIONSWIDTH, 10, /* Speed */
  111.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP, 0,
  112.      (APTR)&hp11text[11], NULL, 0, &hp11item[12] },
  113.  
  114.       { &hp11item[13], 50, 9, SPEEDWIDTH, 10, /* Slow */
  115.         ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] CHECKIT ] CHECKED, 2,
  116.         (APTR)&hp11text[12], NULL, 0, NULL },
  117.  
  118.       { NULL, 50, 19, SPEEDWIDTH, 10, /* Fast */
  119.         ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] CHECKIT, 1,
  120.         (APTR)&hp11text[13], NULL, 0, NULL },
  121.  
  122.    { NULL, 0, 20, SPEEDWIDTH, 10, /* Icons */
  123.      ITEMTEXT ] ITEMENABLED ] HIGHCOMP ] CHECKIT ] CHECKED, 0,
  124.      (APTR)&hp11text[14], NULL, 0, NULL }
  125. };
  126.  
  127. /* The main menu options */
  128. struct Menu hp11menu[] = {
  129.    { &hp11menu[1], 0, 0, 80, 9, MENUENABLED, "Project", &hp11item[0] },
  130.    { &hp11menu[2], 100, 0, 50, 9, MENUENABLED, "Edit", &hp11item[6] },
  131.    { NULL, 170, 0, 80, 9, MENUENABLED, "Options", &hp11item[8] }
  132. };
  133.  
  134. /* state of Icons menu option */
  135. static BOOL icons_on = TRUE;
  136.  
  137. /* filename for save & open, window title */
  138. static char filename[100], undo[100], winname[110];
  139.  
  140. /* Structures for file requester */
  141. /* ----------------------------- */
  142.  
  143. static WORD shadowvert[] = { /* Points for shadow of ok/cancel box  */
  144.    2, 15,
  145.    2, 17,
  146.    82, 17,
  147.    82, 1,
  148.    80, 1
  149. };
  150. static struct Border cancelshadow = { 0, 0, 2, 0, JAM1, 5, shadowvert, NULL };
  151. static WORD cancelvert[] = { /* Actual box */
  152.    -1, -1,
  153.    80, -1,
  154.    80, 15,
  155.    -1, 15,
  156.    -1, -1
  157. };
  158. /* This defines a box with shadow 80 points wide */
  159. static struct Border cancelborder = { 0, 0, 2, 0, JAM1, 5, cancelvert,
  160.  &cancelshadow };
  161.  
  162. /* The cancel gadget */
  163. static struct IntuiText canceltext = { 2, 1, JAM1, 10, 4, &topaz9attr,
  164.  "Cancel", NULL };
  165. static struct Gadget cancelgadget = {
  166.    NULL,
  167.    -100, -25, 80, 15, /* it is 100 points from the right, 25 points from
  168.     the bottom & measures 80x15 */
  169.    GADGHCOMP ] GRELRIGHT ] GRELBOTTOM,
  170.    RELVERIFY ] TOGGLESELECT ] ENDGADGET,
  171.    BOOLGADGET ] REQGADGET,
  172.    (APTR)&cancelborder,
  173.    NULL,
  174.    &canceltext
  175. };
  176.  
  177. static WORD okvert[] = { /* Box thickening */
  178.    0, 0,
  179.    79, 0,
  180.    79, 14,
  181.    0, 14,
  182.    0, 0
  183. };
  184. static struct Border okborder = { 0, 0, 2, 0, JAM1, 5, okvert, &cancelborder };
  185.  
  186. /* Ok gadget */
  187. static struct IntuiText oktext = { 2, 1, JAM1, 30, 4, &topaz9attr, "Ok", NULL
  188.  };
  189. static struct Gadget okgadget = {
  190.    &cancelgadget,
  191.    20, -25, 80, 15,
  192.    GADGHCOMP ] GRELBOTTOM,
  193.    RELVERIFY ] TOGGLESELECT ] ENDGADGET,
  194.    BOOLGADGET ] REQGADGET,
  195.    (APTR)&okborder,
  196.    NULL,
  197.    &oktext
  198. };
  199.  
  200. static WORD bluevert[] = {
  201.    0, 8,
  202.    199, 8
  203. };
  204. static struct Border blueline = { 0, 0, 0, 0, JAM1, 2, bluevert, NULL };
  205.  
  206. static WORD namevert[] = { /* for filename box */
  207.    -1, -1,
  208.    200, -1,
  209.    200, 9,
  210.    -1, 9,
  211.    -1, -1
  212. };
  213. static struct Border nameborder = { 0, 0, 2, 0, JAM1, 5, namevert, &blueline };
  214.  
  215. static struct StringInfo nameinfo = {
  216.    filename, undo,
  217.    0, 100, 0
  218. };
  219.  
  220. static struct IntuiText nametext = { 2, 1, JAM1, -55, 0, &topaz9attr, NULL,
  221.  NULL };
  222.  
  223. /* filename gadget */
  224. static struct Gadget namegadget = {
  225.    &okgadget,
  226.    62, 10, 200, 9,
  227.    GADGHCOMP,
  228.    ENDGADGET,
  229.    STRGADGET ] REQGADGET,
  230.    (APTR)&nameborder,
  231.    NULL,
  232.    &nametext,
  233.    0,
  234.    (APTR)&nameinfo
  235. };
  236.  
  237. static WORD filevert[] = { /* for the complete requester */
  238.    0, 0,
  239.    269, 0,
  240.    269, 59,
  241.    0, 59,
  242.    0, 0
  243. };
  244. static struct Border fileborder = { 0, 0, 2, 0, JAM1, 5, filevert, NULL };
  245.  
  246. /* The actual requester */
  247. static struct Requester filereq = {
  248.    NULL,
  249.    25, 65,
  250.    270, 60,
  251.    0, 0,
  252.    &namegadget,
  253.    &fileborder,
  254.    NULL,
  255.    0,
  256.    1
  257. };
  258.  
  259. /* Message requester */
  260. /* ----------------- */
  261. static struct IntuiText msgtext = { 2, 1, JAM1, 10, 10, &topaz9attr, NULL, NULL
  262.  };
  263.  
  264. static struct Gadget msgokgadget = {
  265.    NULL,
  266.    20, -25, 80, 15, /* Message inits LeftEdge */
  267.    GADGHCOMP ] GRELBOTTOM,
  268.    RELVERIFY ] TOGGLESELECT ] ENDGADGET,
  269.    BOOLGADGET ] REQGADGET,
  270.    (APTR)&okborder,
  271.    NULL,
  272.    &oktext
  273. };
  274.  
  275. static WORD msgvert[][2] = {
  276.    0, 0,
  277.    0, 0,
  278.    0, 59,
  279.    0, 59,
  280.    0, 0
  281. };
  282. static struct Border msgborder = { 0, 0, 2, 0, JAM1, 5, msgvert, NULL };
  283.  
  284. static struct Requester msgreq = {
  285.    NULL,
  286.    0, 65, /* LeftEdge is initialised by Message */
  287.    0, 60, /* Width also */
  288.    0, 0,
  289.    &msgokgadget,
  290.    &msgborder,
  291.    &msgtext,
  292.    0,
  293.    1
  294. };
  295.  
  296. /* struct DiskObject {
  297.     int a;
  298. };  Little problem: DiskObject def lost !!! */
  299.  
  300. struct Library *IconBase; /* for the icon library */
  301. struct ArpBase *ArpBase; /* Arp lib */
  302. extern char tool[]; /* Path to hp11 program */
  303. extern struct DiskObject prog_icon;
  304. static BOOL clip;
  305.  
  306. void LoadProg(void), OpenProg(void), StoreProg(void), SaveProg(void),
  307.  Copy(void), Paste(void);
  308.  
  309. BOOL MenusInit(argc, argv)
  310. int argc;
  311. APTR argv;
  312. #define argw ((struct WBStartup *)argv)
  313. #define arg1 (argw->sm_ArgList[1])
  314. {
  315.    char path[PATHLEN];
  316.  
  317.    topaz9 = OpenFont(&topaz9attr); /* Open the desired font */
  318.  
  319.    IconBase = OpenLibrary("icon.library", 0);
  320.    if (!IconBase) { /* no icon library, disable icons */
  321.       icons_on = FALSE;
  322.       hp11item[14].Flags &= ~(CHECKED ] ITEMENABLED);
  323.    }
  324.    ArpBase = OpenLibrary("arp.library", 0);
  325.  
  326.    /* Set up tool path */
  327.    strcat(strcpy(tool, hp11path), hp11name);
  328.  
  329.    if (!(clip = !CBOpen(0))) /* Disable clip options if no clipboard */
  330.       hp11menu[1].Flags = NULL;
  331.  
  332.    SetMenuStrip(hp11, hp11menu);
  333.  
  334.    if (argc != 0) { /* CLI */
  335.       icons_on = FALSE;
  336.       hp11item[14].Flags &= ~CHECKED; /* by default, no icons from cli */
  337.       if (argc > 1) { /* argument */
  338.          strcpy(filename, ((char **)argv)[1]);
  339.          LoadProg();
  340.       }
  341.    }
  342.    else if (argw->sm_NumArgs > 1) { /* workbench, with argument */
  343.       if (!mygetpath(path, arg1.wa_Lock)) path[0] = '\0';
  344.       strcpy(filename, strcat(path, arg1.wa_Name));
  345.       LoadProg();
  346.    }
  347.    return(TRUE);
  348. }
  349. #undef arg1
  350. #undef argw
  351.  
  352. void MenusCleanUp()
  353. {
  354.    if (hp11) ClearMenuStrip(hp11);
  355.    if (clip) CBClose();
  356.    if (ArpBase) CloseLibrary(ArpBase);
  357.    if (IconBase) CloseLibrary(IconBase);
  358.    if (topaz9) CloseFont(topaz9);
  359. }
  360.  
  361. /* Enable menus */
  362. void MenusOn(void)
  363. {
  364.    SetMenuStrip(hp11, hp11menu);
  365. }
  366.  
  367. /* Disable menus */
  368. void MenusOff(void)
  369. {
  370.    ClearMenuStrip(hp11);
  371. }
  372.  
  373. void EditOn(void)
  374. {
  375.    if (clip) OnMenu(hp11, SHIFTMENU(1) ] SHIFTITEM(NOITEM));
  376. }
  377.  
  378. void EditOff(void)
  379. {
  380.    OffMenu(hp11, SHIFTMENU(1) ] SHIFTITEM(NOITEM));
  381. }
  382.  
  383. /* The menu handler, number represents the chosen option */
  384. int MenuHandler(UWORD number)
  385. {
  386.    register struct MenuItem *item;
  387.    register int key = -1;
  388.  
  389.    MenusOff(); /* Disable menus */
  390.  
  391.    while (number != MENUNULL) {
  392.  
  393.       switch (MENUNUM(number)) {
  394.          case 0: /* Project */
  395.             switch (ITEMNUM(number)) {
  396.                case 0: /* New */ HP11ColdReset(); key = BRESET; break; /* back to main
  397.  loop */
  398.                case 1: /* Open */ OpenProg(); key = BRESET; break;
  399.                case 2: /* Save */ StoreProg(); break;
  400.                case 3: /* Save as */ SaveProg(); break;
  401.                case 4: /* Print */ break;
  402.                case 5: /* Quit */ quit = TRUE; key = BRESET; break;
  403.             }
  404.             break;
  405.          case 1: /* Edit */
  406.             switch (ITEMNUM(number)) {
  407.                case 0: /* Copy */ Copy(); break;
  408.                case 1: /* Paste */ Paste(); key = BDISPLAY; break;
  409.             }
  410.             break;
  411.          case 2: /* Options */
  412.             switch (ITEMNUM(number)) {
  413.                case 0: /* Radix */
  414.                   comma = SUBNUM(number); /* false for Point, true for Comma */
  415.                   key = BDISPLAY; /* Redisplay */
  416.                   break;
  417.                case 1: /* Speed */
  418.                   fast = SUBNUM(number); /* false for Slow, true for Fast */
  419.                   break;
  420.                case 2: /* Icons */
  421.                   icons_on = !icons_on;
  422.  
  423.                   /* Toggle flag */
  424.                   if (icons_on) hp11item[14].Flags ]= CHECKED;
  425.                   else hp11item[14].Flags &= ~CHECKED;
  426.  
  427.                   break;
  428.             }
  429.             break;
  430.       }
  431.  
  432.       item = ItemAddress(hp11menu, (long)number);
  433.       number = item->NextSelect;
  434.    }
  435.  
  436.    MenusOn();
  437.    return(key);
  438. }
  439.  
  440. /* Display an error message */
  441. void Message(text)
  442. char *text;
  443. {
  444.    register int width;
  445.  
  446.    msgtext.IText = text;
  447.    width = IntuiTextLength(&msgtext) + 20; /* width of requester */
  448.    if (width < 100) width = 100; /* min width */
  449.    msgokgadget.Flags &= ~SELECTED;
  450.    msgreq.Width = width;
  451.    msgreq.LeftEdge = (HP11WIDTH - width) >> 1; /* center rqeuester */
  452.    msgokgadget.LeftEdge = (width >> 1) - 40; /* center OK */
  453.    msgvert[1][0] = width - 1;
  454.    msgvert[2][0] = width - 1;
  455.  
  456.    Request(&msgreq, hp11);
  457. }
  458.  
  459. /* Read a file name, text is displayed to the left of the name box.
  460.   Return FALSE if cancel selected, TRUE otherwise */
  461. static BOOL GetFile(char *text)
  462. {
  463.    ULONG saveIDCMP;
  464.    struct IntuiMessage *msg;
  465.    int done;
  466.  
  467.    if (ArpBase) /* Use arp file req */
  468.    {
  469.       static char directory[DSIZE + 1];
  470.       static struct FileRequester FR;
  471.  
  472.       filename[0] = '\0';
  473.       FR.fr_Hail = text;
  474.       FR.fr_File = filename;
  475.       FR.fr_Dir = directory;
  476.  
  477.       if (FileRequest(&FR))
  478.       {
  479.           long lock = Lock(directory, SHARED_LOCK);
  480.  
  481.           if (lock)
  482.           {
  483.               CurrentDir(lock);
  484.               return TRUE;
  485.           }
  486.       }
  487.       return FALSE;
  488.    }
  489.    else
  490.    {
  491.       nametext.IText = text;
  492.       okgadget.Flags &= ~SELECTED;
  493.       cancelgadget.Flags &= ~SELECTED;
  494.  
  495.       saveIDCMP = hp11->IDCMPFlags;
  496.       ModifyIDCMP(hp11, REQCLEAR ] REQSET);
  497.       Request(&filereq, hp11);
  498.       do {
  499.              WaitPort(hp11->UserPort); /* Wait for requester to appear */
  500.          msg = GetMsg(hp11->UserPort);
  501.          done = msg->Class == REQSET;
  502.          ReplyMsg(msg);
  503.       } while (!done);
  504.  
  505.       ActivateGadget(&namegadget, hp11, &filereq);
  506.  
  507.       do {
  508.          WaitPort(hp11->UserPort); /* Wait for requester to disappear */
  509.          msg = GetMsg(hp11->UserPort);
  510.          done = msg->Class == REQCLEAR;
  511.          ReplyMsg(msg);
  512.       } while (!done);
  513.  
  514.       ModifyIDCMP(hp11, saveIDCMP);
  515.  
  516.       if (!(cancelgadget.Flags & SELECTED))
  517.       {
  518.          CurrentDir(DupLock(CurrentDir(0)));
  519.          return TRUE;
  520.       }
  521.       else
  522.          return FALSE;
  523.    }
  524. }
  525.  
  526. static void SetTitle(void)
  527. {
  528.    SetWindowTitles(hp11, strcat(strcpy(winname, "HP11C - "), filename), (char
  529.  *)(long)-1);
  530. }
  531.  
  532. static int FileType(struct DiskObject *icon, char *type)
  533. {
  534.    char *value;
  535.  
  536.    if (!(value = FindToolType(icon->do_ToolTypes, "FILETYPE"))) return(FALSE);
  537.    return((int)MatchToolValue(value, type));
  538. }
  539.  
  540. static void LoadProg()
  541. {
  542.    LONG file;
  543.    struct Regs newhp11;
  544.    struct DiskObject *icon = NULL;
  545.    BYTE dummy;
  546.  
  547.    if (IconBase && (icon = GetDiskObject(filename)) &&
  548.        !FileType(icon, "HP11")) {
  549.       Message("This isn't an HP11 program");
  550.       goto exit;
  551.    }
  552.  
  553.    if (file = Open(filename, MODE_OLDFILE)) {
  554.       if ((Read(file, (char *)&newhp11, sizeof(struct Regs)) == sizeof(struct
  555.  Regs))
  556.           && (Read(file, &dummy, 1) != 1)) { /* dummy read to check file size */
  557.             hp11r = newhp11; /* Set new internal state */
  558.             running = FALSE; /* Interrupt program */
  559.             PC = 0;
  560.             retCnt = 0;
  561.             ENABLE();
  562.  
  563.             SetTitle();
  564.          }
  565.          else Message("This isn't an HP11 program");
  566.       Close(file);
  567.    }
  568.    else Message("Couldn't open file");
  569.  
  570. exit: if (icon) FreeDiskObject(icon);
  571. }
  572.  
  573. /* Save current state under current filename */
  574. static void StoreProg()
  575. {
  576.    LONG file;
  577.    struct DiskObject *temp_icon;
  578.  
  579.    file = Open(filename, MODE_NEWFILE);
  580.    if (!file) Message("Couldn't open file");
  581.    else {
  582.       if (Write(file, (char *)&hp11r, sizeof(struct Regs)) != sizeof(struct
  583.  Regs))
  584.          Message("Error writing the file");
  585.       else {
  586.          SetTitle();
  587.          if (icons_on)
  588.             if (!(temp_icon = GetDiskObject(filename)))
  589.                PutDiskObject(filename, &prog_icon);
  590.             else FreeDiskObject(temp_icon);
  591.       }
  592.       Close(file);
  593.    }
  594. }
  595.  
  596. /* Save current state under a filename */
  597. static void SaveProg()
  598. {
  599.    BPTR cdir, new;
  600.  
  601.    CurrentDir(cdir = CurrentDir(0));
  602.  
  603.    if (GetFile("Save:"))
  604.    {
  605.       StoreProg();
  606.       if (new = CurrentDir(cdir)) UnLock(new);
  607.    }
  608. }
  609.  
  610. /* Load the hp11 state */
  611. static void OpenProg()
  612. {
  613.    BPTR cdir, new;
  614.  
  615.    CurrentDir(cdir = CurrentDir(0));
  616.  
  617.    if (GetFile("Open:")) /* Get file name */
  618.    {
  619.       LoadProg();
  620.       if (new = CurrentDir(cdir)) UnLock(new);
  621.    }
  622. }
  623.  
  624. static void Copy()
  625. {
  626.    CBCut(NbStr(X));
  627. }
  628.  
  629. static void Paste()
  630. {
  631.    char buf[256];
  632.  
  633.    if (CBPaste(buf)) {
  634.       Enter(); ENABLE();
  635.       X = Check(atof(buf));
  636.    }
  637. }
  638.  
  639.