The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.

Moderator: pjdixit

#50728 by Mark F. Madura
Wed Oct 20, 2010 2:00 pm
Code: Select all{
DCAL  for Delphi program MenuOptions
}

library MenuOptions;

uses
  UConstants in '..\Header Files\UConstants.pas',
  UInterfaces in '..\Header Files\UInterfaces.pas',
  UInterfacesRecords in '..\Header Files\UInterfacesRecords.pas',
  URecords in '..\Header Files\URecords.pas',
  UVariables in '..\Header Files\UVariables.pas';

{$E dmx}  //dmx is the extension for DCAL Dll's

//The values stored in the records you define here will be rememberd
//between dispatcher calls because they are pushed onto the command stack
type
  MenuOptL = record
    state: asint;
    case byte of
      0: (getp: getpointArg);
  end;
  PMenuOptL = ^MenuOptL;

//Main Function (Re-entrant State Machine)
function MenuOptions_Main(act : action; pl, pargs : Pointer) : wantType;
//The values stored in variables you define here will not be retained
//between dispatcher calls because they are not pushed onto the stack
var
   retval : asint;
   l : PMenuOptL;
begin
   l := PMenuOptL(pl);

   {Section 3: Aagain - Return to menus and wait for input}
   if act = aagain then begin  { Re-entrant section }
      case l.state of { Case }
         1 :
         begin { 1: Main Menu }
            //If a key was pressed or a menu button was selected...
            if l.getp.Result = res_escape then begin
               case l.getp.key of
                  f1 : l.state := 1;  { Option 1.0 }
                  f2 : l.state := 1;  { Option 2.0 }
                  f3 : l.state := 1;  { Option 3.0 }

                  s9 : l.state := 2;  { Options 1 Sub-menu }

                  s0 : l.state := 0;  { Exit - Macro }
               end;  { Which key was pressed? }
            end;  { Was a key pressed or menu selected? }
         end; { 1: Main Menu }
         2 :
         begin { 2: Options 1 Menu }
            //If a key was pressed or a menu button was selected...
            if l.getp.Result = res_escape then begin
               case l.getp.key of
                  f1 : l.state := 2;  { Option 1.1 }
                  f2 : l.state := 2;  { Option 2.1}
                  f3 : l.state := 2;  { Option 3.1 }

                  s9 : l.state := 3;  { Options 2 Sub-menu }

                  s0 : l.state := 1;  { Exit - To previous menu }
               end;  { Which key was pressed }
            end;  { Was a key pressed or menu selected? }
         end; { 2: Options 1 Menu }
         3 :
         begin { 3: Options 2 Menu }
            //If a key was pressed or a menu button was selected...
            if l.getp.Result = res_escape then begin
               case l.getp.key of
                  f1 : l.state := 3;  { Option 1.2 }
                  f2 : l.state := 3;  { Option 2.2 }
                  f3 : l.state := 3;  { Option 3.2 }

                  s9 : l.state := 4;  { Options 3 }

                  s0 : l.state := 2;  { Exit - To previous menu }
               end;  { Which key was pressed }
            end;  { Was a key pressed or menu selected? }
         end; { 3: Options 2 Menu }
         4 :
         begin { 4: Options 3 Menu }
            //If a key was pressed or a menu button was selected...
            if l.getp.Result = res_escape then begin
               case l.getp.key of
                  f1 : l.state := 4;  { Option 1.3 }
                  f2 : l.state := 4;  { Option 2.3 }
                  f3 : l.state := 4;  { Option 3.3 }

                  s0 : l.state := 3;  { Exit - To previous menu }
               end;  { Which key was pressed }
            end;  { Was a key pressed or menu selected? }
         end; { 4: Options 3 Menu }
      else
         l.state := 0;
      end; { Case }
   end;  { Re-entrant Section }

    {Section 2: Afirst - Tasks to perform only once}
    if act = Afirst then begin  //Initialize local state and other variables
      wrterr('Hello World Macro - Version 1.0');
      l.state := 1;
    end

    {Section 4: Alast - If your macro has been interrupted by user action}
    else if act = Alast then begin
      //If you're going to get blown off the stack...
      //(i.e.) the user pressed a hotkey,
      //then this is your last chance to clean up temporary data.
    end

    {Section 1: AlSize - Allocate memory on stack for local variables}
    else if act = AlSize then begin
      SetLocalSize(sizeof(l^));
    end;

    if act <> alsize then begin  { Action section }
      case l.state of
        1 :
        begin  { 1: Main Menu }
          wrtlvl('MenuOptions');  //Set Menu Title
          lblsinit;
          lblset(1, 'Option 1.0', 'Set option one values');
          lblset(2, 'Option 2.0', 'Set option two values');
          lblset(3, 'Option 3.0', 'Set option three values');

          lblset(19, 'Options 1', 'Options Two Menu');
          lblson1;
          getpoint(l.getp, retval);
        end;  { 1: Main Menu }
        2:
        begin  { 2: Options 1 Sub-menu }
          wrtlvl('Options 1');  //Set Menu Title
          lblsinit;
          lblset(1, 'Option 1.1', 'Set option one values');
          lblset(2, 'Option 2.1', 'Set option two values');
          lblset(3, 'Option 3.1', 'Set option three values');

          lblset(19, 'Options 2', 'Options Two Menu');
          lblson1;
          getpoint(l.getp, retval);
        end;  { 2: Options 1 Sub-menu }
        3:
        begin  { 3: Options 2 Sub-menu }
          wrtlvl('Options 2');  //Set Menu Title
          lblsinit;
          lblset(1, 'Option 1.2', 'Set option one values');
          lblset(2, 'Option 2.2', 'Set option two values');
          lblset(3, 'Option 3.2', 'Set option three values');

          lblset(19, 'Options 3', 'Options Two Menu');
          lblson1;
          getpoint(l.getp, retval);
        end;  { 3: Options 2 Sub-menu }
        4:
        begin  { 4: Options 3 Sub-menu }
          wrtlvl('Options 3');  //Set Menu Title
          lblsinit;
          lblset(1, 'Option 1.3', 'Set option one values');
          lblset(2, 'Option 2.3', 'Set option two values');
          lblset(3, 'Option 3.3', 'Set option three values');

          lblson1;
          getpoint(l.getp, retval);
        end;  { 4: Options 3 Sub-menu }
      else
        retval := XDone; //Don't go back to Aagain
      end; { Case }
    end; { Action section }
    Result := retval;
end; { MenuOptions_main }

function Main(dcalstate : asint; act : action; pl, pargs : Pointer) : wantType; stdcall;
begin
   case dcalstate of
      XDcalStateBegin : Result := MenuOptions_main(act, pl, pargs);
         else
            Result := XDone;{Necessary}
   end;
end;
//End of Main Function (Re-entrant State Machine)

exports
   Main;{This is the entry function that will be called by DataCAD.
         All DCAL Dlls will have this function.}

begin

end.
#50733 by rod_walker
Wed Oct 20, 2010 5:44 pm
My major stumbling block has been solved.
Thank you Mark.

Rod Walker

Who is online

Users browsing this forum: No registered users and 2 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for AEC Professionals Since 1984