Cmac PUT_BOX replacement

Home Forums Multi-Edit Support Cmac PUT_BOX replacement

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  HerbJones 5 months, 2 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #22681

    HerbJones
    Participant

    I am trying to update from DOS ME to ME 2008. The PUT_BOX command for some strange reason was not carried into ME 2008. I now have many Cmac macros that will not compile because they use the PUT_BOX command for user input. Is there example replacement code that someone can offer to replace this important command?

    I really just need something easy to carry a user selection into a variable.

    Thanks in advance.

    #22685

    Clay Martin
    Keymaster
    #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);

    }

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

You must be logged in to reply to this topic.