home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / DIALOG.ZIP / DIALOGER.DOC next >
Encoding:
Text File  |  1993-01-04  |  9.7 KB  |  238 lines

  1.  ┌────────────────────────────────────────────────────────────────────────────┐
  2.  │                                                                            │
  3.  │                   DIALOG BOX MAKER                                         │
  4.  │                     Version 1.02                                           │
  5.  │                                                                            │
  6.  │                by David R. Grigg                                           │
  7.  │                   1556 Main Road,                                          │
  8.  │                   Research, Victoria 3095,                                 │
  9.  │                   AUSTRALIA.                                               │
  10.  │                                                                            │
  11.  │                  (Compuserve 76264,2530)                                   │
  12.  │                                                                            │
  13.  │  Takes a text file with a design of a dialog box and generates the         │
  14.  │  appropriate TurboVision code to generate that box.                        │
  15.  │                                                                            │
  16.  │  If you find this useful, send me a postcard, a letter, or your favorite   │
  17.  │  utility program.  Appreciation, not money required!                       │
  18.  │                                                                            │
  19.  └────────────────────────────────────────────────────────────────────────────┘
  20.  
  21.  Surely, I say to myself, someone else must have written this program!
  22.  But if they have, I can't find it on Compuserve.
  23.  
  24.  After writing my first applications using Turbo Vision, and having to
  25.  hand-construct my first large dialog box, I nearly threw up my hands in
  26.  despair.  There had to be a better way!  So, being a lazy kind of
  27.  person, I wrote this program.
  28.  
  29.  DIALOGER takes an ASCII text file in which you have created the design
  30.  of a dialog box, and turns it into a whole completed procedure to
  31.  create that dialog box.  All you need do is read the new file into
  32.  your program and compile it.  This (I think) is the best thing since
  33.  sliced bread.
  34.  
  35.  Here's a sample text file with a dialog box design in it:
  36.  
  37. ((((((((((((((((((Text File starts with following line:)))))))))))))))))))))
  38.  
  39.  Label:
  40.  <------------------------------------->
  41.  
  42.  Type:                Shape:
  43.  ( ) Branch           [ ] Invisible
  44.  ( ) Indirect         [ ] Plain
  45.  ( ) Jump             [ ] Bevelled
  46.  ( ) Function         [ ] Round
  47.  ( ) Key              [ ] Custom 1
  48.                       [ ] Custom 2
  49.  Data:
  50.  <------------------------------------->
  51.  
  52.  Position:
  53.  X1: <---> Y1: <---> X2: <---> Y2: <--->
  54.  
  55.  {   Ok   }   { Cancel }   { Display }
  56.  
  57. ((((((((((((((((Text file ends with previous line))))))))))))))))))))))))))
  58.  
  59.  ...and here is the code that DIALOGER generated:
  60.  (NOTE by the way that DIALOGER's output is a file with the same name as
  61.  the one you gave it for input, but with a .DIA extension.  I don't check
  62.  to see if such a file already exists, but just overwrite it.  Be warned!)
  63.  
  64.  {--------------------------------------------------------------------------}
  65.  
  66. procedure ShowDialogBox;
  67.    var Dialog: PDialog;
  68.        R: TRect;
  69.        Control: word;
  70.        B: PView;
  71.        DataRecord : record
  72.                       InpLineData1: string[37];
  73.                       RButtonData1: word;
  74.                       CBoxData1: word;
  75.                       InpLineData2: string[37];
  76.                       InpLineData3: string[3];
  77.                       InpLineData4: string[3];
  78.                       InpLineData5: string[3];
  79.                       InpLineData6: string[3];
  80.                     end;
  81.  
  82.    begin
  83.      with DataRecord do begin
  84.        InpLineData1:= '';
  85.        RButtonData1:= 0;
  86.        CBoxData1:= 0;
  87.        InpLineData2:= '';
  88.        InpLineData3:= '';
  89.        InpLineData4:= '';
  90.        InpLineData5:= '';
  91.        InpLineData6:= '';
  92.      end; {with}
  93.      R.Assign(20,0,63,21);
  94.      Dialog:= New(PDialog, Init(R,'Button'));
  95.      with Dialog^ do
  96.        begin
  97.           R.Assign(2,3,41,4);
  98.           B:= New(PInputLine,Init(R,37));
  99.           Insert(B);
  100.           R.Assign(2,2,9,3);
  101.           Insert(New(PLabel,Init(R,'Label:',B)));
  102.           R.Assign(2,6,16,11);
  103.           B:= New(PRadioButtons,Init(R,
  104.             NewSItem('Branch ',
  105.             NewSItem('Indirect ',
  106.             NewSItem('Jump ',
  107.             NewSItem('Function ',
  108.             NewSItem('Key ',
  109.             nil)))))
  110.           ));
  111.           Insert(B);
  112.           R.Assign(2,5,8,6);
  113.           Insert(New(PLabel,Init(R,'Type:',B)));
  114.           R.Assign(23,6,37,12);
  115.           B:= New(PCheckBoxes,Init(R,
  116.             NewSItem('Invisible',
  117.             NewSItem('Plain',
  118.             NewSItem('Bevelled',
  119.             NewSItem('Round',
  120.             NewSItem('Custom_1',
  121.             NewSItem('Custom_2',
  122.             nil))))))
  123.           ));
  124.           Insert(B);
  125.           R.Assign(23,5,30,6);
  126.           Insert(New(PLabel,Init(R,'Shape:',B)));
  127.           R.Assign(2,13,41,14);
  128.           B:= New(PInputLine,Init(R,37));
  129.           Insert(B);
  130.           R.Assign(2,12,8,13);
  131.           Insert(New(PLabel,Init(R,'Data:',B)));
  132.           R.Assign(6,16,11,17);
  133.           B:= New(PInputLine,Init(R,3));
  134.           Insert(B);
  135.           R.Assign(2,16,6,17);
  136.           Insert(New(PLabel,Init(R,'X1:',B)));
  137.           R.Assign(16,16,21,17);
  138.           B:= New(PInputLine,Init(R,3));
  139.           Insert(B);
  140.           R.Assign(12,16,16,17);
  141.           Insert(New(PLabel,Init(R,'Y1:',B)));
  142.           R.Assign(26,16,31,17);
  143.           B:= New(PInputLine,Init(R,3));
  144.           Insert(B);
  145.           R.Assign(22,16,26,17);
  146.           Insert(New(PLabel,Init(R,'X2:',B)));
  147.           R.Assign(36,16,41,17);
  148.           B:= New(PInputLine,Init(R,3));
  149.           Insert(B);
  150.           R.Assign(32,16,36,17);
  151.           Insert(New(PLabel,Init(R,'Y2:',B)));
  152.           R.Assign(2,18,12,20);
  153.           Insert(New(PButton,Init(R,'Ok',cmOk,bfNormal)));
  154.           R.Assign(15,18,25,20);
  155.           Insert(New(PButton,Init(R,'Cancel',cmCancel,bfNormal)));
  156.           R.Assign(28,18,39,20);
  157.           Insert(New(PButton,Init(R,'Display',cmDisplay,bfNormal)));
  158.           R.Assign(2,15,11,16);
  159.           B:= New(PStaticText,Init(R,'Position:'));
  160.           Insert(B);
  161.           SetData(DataRecord);
  162.        end; {with}
  163.      Control:= Desktop^.ExecView(Dialog);
  164.      if Control<>cmCancel
  165.        then begin
  166.                Dialog^.GetData(DataRecord);
  167.             end;
  168.      Dispose(Dialog,Done);
  169.    end; {ShowDialogBox}
  170.  
  171.  {--------------------------------------------------------------------------}
  172.  
  173.  Isn't this better than coding all the above yourself?
  174.  
  175.  As you can see, DIALOGER handles Radio Buttons, Check Boxes, Input Lines,
  176.  Labels and Static Text.
  177.  
  178.  Naturally, there are some restrictions on the format of the input ASCII file,
  179.  but they are very easy to understand and trivial to implement.
  180.  
  181.  The following rules apply:
  182.  
  183.      INPUT LINES are marked by '<' at the start and '>' at the end.
  184.             The hyphens inbetween are not needed, but I think they help
  185.             you see how the finished dialog box will look.  They also
  186.             indicate how many input characters will fit.
  187.  
  188.      RADIO BUTTONS are marked out by '( )' characters and must be immediately
  189.             followed by the choice text, with only one space separating the
  190.             choice text from the closing ')' character.
  191.             They must run down the page with no gaps between choices.
  192.  
  193.      CHECK BOXES are exactly as for Radio Buttons, but the delimiting
  194.             characters are '[ ]'.
  195.  
  196.      BUTTONS are marked out by '{' and '}'.  The text between these
  197.             characters is considered to be its label.  NOTE that
  198.             DIALOGER will also use the label to bind a cmXXXXX command
  199.             to the button, eg a label such as 'Display' makes the code
  200.             bind a 'cmDisplay' command to the button.  This is likely to
  201.             stop your program compiling, unless you take care to define
  202.             these commands.  This also means that button labels must be
  203.             single words, ie include no embedded spaces, unless you are
  204.             happy to fix up the code manually after generating it.
  205.  
  206.      LABELS: This was the hardest thing to implement.  When is a bit of
  207.             text a label and when is it static text?  My rule is that a
  208.             label must end in a colon ':', and must start either to the
  209.             left of its associated input line, radio buttons, etc, or
  210.             must be placed immediately above, with the first character over
  211.             the delimiting character, eg the ( of a set of Radio Buttons.
  212.  
  213.      STATIC TEXT: is anything that isn't one of the above.
  214.  
  215.      TEXT: Version 1.0 of DIALOGER required that spaces within a
  216.            label or within a piece of static text be replaced by
  217.            underline characters.  Quite frankly, I found this a pain
  218.            in the neck, especially for long bits of static text.  So the
  219.            latest version is smarter in this respect.  It recognises
  220.            a double space rather than a single space as the end of a bit of
  221.            text.
  222.  
  223.  That's it.
  224.  
  225.  Naturally, you will still need to work on the generated code to make it
  226.  suitable for your own application.  You might, for example, want the
  227.  program to allow input text longer than the visible area on the screen.
  228.  If so, you will need to get in and change some of the numbers in the
  229.  generated code.
  230.  
  231.  
  232.  Please note that this is the first version of DIALOGER, and I expect there
  233.  are likely to be bugs in it.  I'd be grateful for bug reports and other
  234.  comments.
  235.  
  236.     --- David R Grigg.
  237.         2 May 1991.
  238.