home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff274.lzh / HP11 / amiga / menus.c < prev    next >
C/C++ Source or Header  |  1989-11-16  |  16KB  |  627 lines

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