HerbJones

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Cmac PUT_BOX replacement #23710
    HerbJones
    Participant

    This was the toughest hurdle for me to get over when switching from DOS ME to ME2008. The supplied example code was not thoroughly documented and was not real clear.

    Once I got it figured out, I found that the new code is much cleaner and is easier to write than the DOS method.

    To save someone hassles in the future, I did figure out stripped down code to handle user prompts and inputs.

    Here are five examples of how to interface with a user and get their input. Examples include how to ask for an Integer, Text, Real Number, using Radio Buttons (very cool!), and a simple single push button to have them simple acknowledge a message

    Hope it helps!
    ———————————————-
    #include WINDOW.SH //header file that contains the def for DlgExecute – IMPORTANT!
    #include DIALOG.SH //header file that contains the def for DlgExecute – IMPORTANT!

    macro INTEGER FROM EDIT TRANS {

    #define OK_title_ctrl 101
    #define OK_ctrl 102

    #define PushBtn_ctrl 1020
    #define integer_ctrl 1004

    str press_s;
    int dlg, press_i;

    Make_Message(“”); // clear make_message before starting…

    refresh = false; /* Don’t refresh the screen */

    DlgCreate(dlg); // used to create the HANDLE of the dialog.

    //DlgAddCtrl( dlg, DLG_Static, “DLG_&INTEGER:”, 1, Dlg_PosOffset | 1, 13, 0, integer_title_ctrl, 0, “” );
    DlgAddCtrl( dlg, DLG_Integer, “”, Dlg_PosOffset | 0, Dlg_PosOffset, 18, 0, integer_ctrl, 0, “” );

    DlgAddCtrl(dlg, DLG_PushButton, “&OK”, 0, Dlg_PosOffset | Dlg_Units | 15,Dlg_StanBtnWidth, 0, OK_ctrl, Dlgf_DefButton, “/R=1”); //101 handle of ok_ctrl, /R=1 tells prompt Oselection is made and exit
    DlgAddCtrl(dlg, DLG_PushButton, “&Cancel”, Dlg_PosOffset | 12, Dlg_PosOffset, Dlg_StanBtnWidth, 0, pushbtn_ctrl, 0, “/R=3” );

    // DLGEXECUTE actually invokes the dialog box
    press_i=DlgExecute(dlg,integer_ctrl, “Enter Integer…”,””, “”,0); //1text_ctrl = will initially be highlighted
    if ((press_i==0)|(press_i==3)){Make_message(‘Macro cancelled’); goto FIN;};//ESC OR CANCEL
    //press_s = DlgGetStr(dlg,variable); // for strings
    press_i = DlgGetInt(dlg,integer_ctrl); // for integers
    //press_i=0;

    //Check on which has variable set.
    //press_s=(DlgGetStr(dlg,mbtnstr_ctrl));
    //press_s = DlgGetStr(dlg,text_ctrl); // for strings

    Make_Message(“Entered…” + str(press_i));
    FIN:
    }
    ——————————————————–
    #include WINDOW.SH //header file that contains the def for DlgExecute – IMPORTANT!
    #include DIALOG.SH //header file that contains the def for DlgExecute – IMPORTANT!

    macro TEXT FROM EDIT TRANS {

    #define text_ctrl 1002 //needs any old unique handle

    #define OK_ctrl 102
    #define PushBtn_ctrl 1020

    str press_s;
    int dlg, press_i;

    Make_Message(“”); // clear make_message before starting…

    refresh = false; /* Don’t refresh the screen */

    pressloop:
    DlgCreate(dlg); // used to create the HANDLE of the dialog.

    DlgAddCtrl(dlg, DLG_Text, “”, Dlg_PosOffset | 0, Dlg_PosOffset, 25, 0, text_ctrl, 0, “”);

    DlgAddCtrl(dlg, DLG_PushButton, “&OK”, 2, Dlg_PosOffset | Dlg_Units | 15,Dlg_StanBtnWidth, 0, OK_ctrl, Dlgf_DefButton, “/R=1”); //101 handle of ok_ctrl, /R=1 tells prompt Oselection is made and exit
    DlgAddCtrl(dlg, DLG_PushButton, “&Cancel”, Dlg_PosOffset | 12, Dlg_PosOffset, Dlg_StanBtnWidth, 0, pushbtn_ctrl, 0, “/R=3” );

    // DLGEXECUTE actually invokes the dialog box
    press_i=DlgExecute(dlg,text_ctrl, “Enter Text…”,””, “”,0); //1text_ctrl = will initially be highlighted

    if ((press_i==0)|(press_i==3)){Make_message(‘Macro cancelled’); goto FIN;};//ESC OR CANCEL
    //press_i = DlgGetInt(dlg,Radio2_ctrl // for integers
    //press_i=0;

    //Check on which has variable set.
    press_s = DlgGetStr(dlg,text_ctrl); // for strings
    if(press_s==”) {goto pressloop;};

    Make_Message(“Entered…” + press_s);
    fin:
    }
    —————————————————————-
    #include WINDOW.SH //header file that contains the def for DlgExecute – IMPORTANT!
    #include DIALOG.SH //header file that contains the def for DlgExecute – IMPORTANT!

    macro REALNO FROM EDIT TRANS {

    #define realnum_title_ctrl 1005
    #define realnum_ctrl 1006

    #define OK_ctrl 102
    #define PushBtn_ctrl 1020

    str press_s;
    int dlg, press_i,COUNT;
    real press_r;

    Make_Message(“”); // clear make_message before starting…

    refresh = false; /* Don’t refresh the screen */

    REENTER:
    DlgCreate(dlg); // used to create the HANDLE of the dialog.

    //DlgAddCtrl( dlg, DLG_Static, “DLG_&INTEGER:”, 1, Dlg_PosOffset | 1, 13, 0, integer_title_ctrl, 0, “” );
    DlgAddCtrl( dlg, DLG_RealNumber, “”, Dlg_PosOffset | 0, Dlg_PosOffset, 21, 0, realnum_ctrl, 0, “” );

    DlgAddCtrl(dlg, DLG_PushButton, “&OK”, 0, Dlg_PosOffset | Dlg_Units | 15,Dlg_StanBtnWidth, 0, OK_ctrl, Dlgf_DefButton, “/R=1”); //101 handle of ok_ctrl, /R=1 tells prompt Oselection is made and exit
    DlgAddCtrl(dlg, DLG_PushButton, “&Cancel”, Dlg_PosOffset | 12, Dlg_PosOffset, Dlg_StanBtnWidth, 0, pushbtn_ctrl, 0, “/R=3” );

    // DLGEXECUTE actually invokes the dialog box
    press_i=DlgExecute(dlg,realnum_ctrl, “Enter Real No…”,””, “”,0); //1text_ctrl = will initially be highlighted
    if ((press_i==0)|(press_i==3)){Make_message(‘Macro cancelled’); goto FIN;};//ESC OR CANCEL

    press_s = DlgGetstr(dlg,realnum_ctrl);

    IF(RVAL(PRESS_R,PRESS_S)!=0) {
    Make_message(PRESS_S + ” Is Not A Real Number – Re-enter!”); //1text_ctrl = will initially be highlighted
    GOTO REENTER;
    };

    Make_Message(“Entered…” + RSTR(Press_R,3,3));
    fin:
    }
    ————————————————————–
    #include WINDOW.SH //header file that contains the def for DlgExecute – IMPORTANT!
    #include DIALOG.SH //header file that contains the def for DlgExecute – IMPORTANT!

    macro RADIO FROM EDIT TRANS {

    #define OK_ctrl 102
    #define PushBtn_ctrl 1020

    #define Radio1_ctrl 1022 //needs any old unique handle
    #define Radio2_ctrl 1023 //needs any old unique handle
    #define Radio3_ctrl 1024 //needs any old unique handle

    str press_s;
    int dlg, press_i,ln,y;

    Make_Message(“”); // clear make_message before starting…

    refresh = false; /* Don’t refresh the screen */

    DlgCreate(dlg); // used to create the HANDLE of the dialog.

    DlgAddCtrl(dlg, DLG_RadioButton, “Radio &1”, Dlg_PosOffset | 1, Dlg_PosOffset, 0, 0, Radio1_ctrl, 0, “” );
    DlgSetInt(dlg,Radio1_ctrl,1);

    DlgAddCtrl(dlg, DLG_RadioButton, “Radio &2”, Dlg_PosOffset | 14, Dlg_PosOffset, 0, 0, Radio2_ctrl, 0, “” );
    DlgSetInt(dlg, Radio2_ctrl, 0);

    DlgAddCtrl(dlg, DLG_RadioButton, “Radio &3”, Dlg_PosOffset | 14, Dlg_PosOffset, 13, 0, Radio3_ctrl, 0, “” );
    DlgSetInt(dlg, Radio3_ctrl, 0);

    DlgAddCtrl(dlg, DLG_PushButton, “&OK”, 11, Dlg_PosOffset | Dlg_Units | 15,Dlg_StanBtnWidth, 0, OK_ctrl, Dlgf_DefButton, “/R=1”); //101 handle of ok_ctrl, /R=1 tells prompt Oselection is made and exit
    DlgAddCtrl(dlg, DLG_PushButton, “&Cancel”, Dlg_PosOffset | 12, Dlg_PosOffset, Dlg_StanBtnWidth, 0, pushbtn_ctrl, 0, “/R=3” );

    press_i=DlgExecute(dlg,Radio1_ctrl, “Choose One…”,””, “”,0); //1text_ctrl = will initially be highlighted
    if ((press_i==0)|(press_i==3)){Make_message(‘Macro cancelled’); goto FIN;};//ESC OR CANCEL

    // DLGEXECUTE actually invokes the dialog box
    //press_i = DlgGetInt(dlg,Radio2_ctrl // for integers
    //press_i=0;

    //Check on which has variable set.
    if(DlgGetInt(dlg,Radio1_ctrl)==1) {press_s=”Radio1″;};
    if(DlgGetInt(dlg,Radio2_ctrl)==1) {press_s=”Radio2″;};
    if(DlgGetInt(dlg,Radio3_ctrl)==1) {press_s=”Radio3″;};

    Make_Message(“Pressed…” + press_s);
    fin:
    }
    ——————————————————-
    #include WINDOW.SH //header file that contains the def for DlgExecute – IMPORTANT!
    #include DIALOG.SH //header file that contains the def for DlgExecute – IMPORTANT!

    macro PBSINGLE FROM EDIT TRANS {

    #define PushBtn_title_ctrl 1019
    #define PushBtn_ctrl 1020

    str press_s;
    int dlg, press_i,ln,y;

    Make_Message(“”); // clear make_message before starting…

    refresh = false; /* Don’t refresh the screen */

    DlgCreate(dlg); // used to create the HANDLE of the dialog.

    DlgAddCtrl( dlg, DLG_PushButton, “&OK”, Dlg_PosOffset | 0, Dlg_PosOffset, 30, 0, pushbtn_ctrl, 0, “” );

    // DLGEXECUTE actually invokes the dialog box
    DlgExecute(dlg,Pushbtn_title_ctrl, “Error – File Not Found”,””, “”,0); //101 = ok_ctrl will initially be highlighted
    //press_s = DlgGetStr(dlg,variable); // for strings
    //press_i = DlgGetInt(dlg,Radio2_ctrl // for integers
    //press_i=0;

    //Check on which has variable set.
    //if(DlgGetInt(dlg,Radio1_ctrl)==1) {press_s=”Radio1″;};
    //if(DlgGetInt(dlg,Radio2_ctrl)==1) {press_s=”Radio2″;};

    Make_Message(“Pressed…” + press_s);

    }

    HerbJones
    Participant

    I noticed this same issue.

    It doesn’t matter how files are opened, when you click on “Files” dragdown, a file history is shown. This file history is wiped when exiting ME2008, i.e. if closed and re-opened, there are no files listed under “File” dragdown.

    Is there a setting somewhere to have it remember file history when closing and opening ME2008?

    Thanks!

    in reply to: How to recognize "Cancel" pushed with DLG in CMAC? #23704
    HerbJones
    Participant

    Took me quite a bit of playing, but I got it figured out just before you sent this.

    You have to do a IntegerVariable=DLGExecute.

    In my code, junki will be the x value in “/R=x”:

    DlgCreate(dlg); // used to create the HANDLE of the dialog.

    DlgAddCtrl( dlg, DLG_RealNumber, “”, Dlg_PosOffset | 0, Dlg_PosOffset, 21, 0, realnum_ctrl, 0, “” );

    DlgAddCtrl(dlg, DLG_PushButton, “&OK”, 7, Dlg_PosOffset | Dlg_Units | 15,Dlg_StanBtnWidth, 0, ok_ctrl, Dlgf_DefButton, “/R=1”); //101 handle of ok_ctrl, /R=1 tells prompt Oselection is made and exit

    DlgAddCtrl(dlg, DLG_PushButton, “&Next Via”, Dlg_PosOffset | 20, Dlg_PosOffset, 30, 0, pushbtn_ctrl, 0, “/R=3” );

    junki=DlgExecute(dlg,realnum_ctrl, “INPUT MATCHING X (xxxx.xxx) or (N)EXT VIA…”,””, “”,0); //1text_ctrl = will initially be highlighted
    //junks=DlgGetStr(Dlg,pushbtn_ctrl); // pressed “Next”

    make_message(“”);
    make_message(str(junki));

    Thanks for the help!

    in reply to: Where is "Debug a Macro" for CMAC support? #23696
    HerbJones
    Participant

    I may not have asked this question properly. In ME for DOS, to debug a CMAC macro, you could single step through your macro. To do so, you had to compile by selecting “Debug CMAC Compile (-M Switch)”. This created a .map file instead of a .mac file under the C:\ME\MAC folder.

    In ME, you could then select “Debug a Macro” in the menu, and you could then single step through your macro, one line at a time.

    With ME2008, under the compile menu, I see the option to do a “CMacWin -M Debug Compile” – which compiles fine, and tells me that the feature exists. However, there isn’t an option to actually run the macro in debug mode. When I drag down the “Macro” section, the only options are Run, Load, and Debug Settings (the “Debug a Macro” selection is missing).

    How do I single step through my Macro once I have “Debug Compiled” it ?

    Thanks for your help

Viewing 4 posts - 1 through 4 (of 4 total)