hexagon logo

Has anyone done any 'advanced' Dialogs in PC-DMIS Basic?

I'm struggling with trying to produce an advanced dialog in PC-DMIS Basic, i.e. one where entry fields are turned on/off when certain radio buttons are clicked, data entry fields filled when selecting a feature in a combo box, etc. etc.

The Help isn't very helpful, and sometimes obviously wrong - unfortunately that help comes verbatim from the Cypress Enable product which is used in PCD, and googling doesn't help...

I've come quite far, but am having large problems with radio groups, as each radio group has it's items numbered 0-N, but the click event doesn't tell me which group has been clicked, just the number and (mangled) caption of the item, which means that I can only have one radio group in each dialog!? Button clicks give me the wrong button caption (I get "Cancel" when I click the "OK" button, and an empty string when clicking the "Cancel" button).

Also, I haven't managed to set the selected value of a listbox or radio group programmatically (DlgText, DlgValue, nothing happens) while the dialog is active.

It's not that I have to do it, it started as a way to try to learn using Dialog events in Basic, hopefully to be able to tell others how to do it, but I'm on the brink of giving up now after two days of experimentation (OK, I've done some SW support during those days, too) and frustration.

Has anyone fiddled with this? Any insights? Examples?
  • Can you post a example of the basic code Andersl?
  • Why use Basic, and not something like an HTA?

    EDIT:
    I read it again and noticed it was more for experimentation and information.
    If I were to do it, I'd use Basic commands wrapped in an HTA; but that's only because I can play around with HTML and VBS. I don't even know if that's possible, but I don't see why not.
    I've never used the Dialog box options or Basic, but I've done something similar with HTA & VBS when trying to come up with a startup program for PC-DMIS
  • That was my initial intention, but with the many quirks I've found, I'm not sure I should recommend anyone to try. That's why I wanted to know if anyone else has already done something, which might help me straighten out some question marks...
  • I never give up, although I may change focus...
  • Total understand. The reason for the request was to make sure I understood your post correctly. I have done something maybe similar to this with a check boxes and using drop down list boxes. Example: If a list box preference selection will change what choices are shown in another drop down list box. I believe this is what you are trying to do with the Radio buttons within a group.

  • Total understand. The reason for the request was to make sure I understood your post correctly. I have done something maybe similar to this with a check boxes and using drop down list boxes. Example: If a list box preference selection will change what choices are shown in another drop down list box. I believe this is what you are trying to do with the Radio buttons within a group.


    Yes, more or less. I have worked out how to react on the radio buttons, the problem there is when I want more than one group of radio buttons in the same dialog, as the .Events doesn't identify the group of the clicked item, only its number in the group. This means that the only way of identification is the text of the radio buttons, which makes the code a translation nightmare, and still don't allow differentiation between two buttons in separate groups if they happen to have the same text (and the same position inside its group). A redesign of the dialog solved the case at hand (the small radio groups changed to combo boxes instead), but it would be good to have a working (translatable) method for the general case.

    My second problem is that I haven't found any way to set what is selected in a combo box - I have two feature selection combo boxes, and when the first is selected, the same value should be selected in number two (but not vice versa). Not really necessary for this program, but definitely something I would like to be able to do.

    And my third problem is that I have to use PutText for some things, which means the code won't work in different languages without *a lot* of work :-(

    A teaser picture of what I'm trying to do (to save a lot of typing):



    which would then add the following to the current pp:

    NEWFEAT1   =GENERIC/CIRCLE,DEPENDENT,CARTESIAN,IN,$
                NOM/XYZ,<SLTR1.TX,SLTR1.TY,SLTR1.TZ>,$
                MEAS/XYZ,<SLTR1.X,SLTR1.Y,SLTR1.Z>,$
                NOM/IJK,<SLTR1.TI,SLTR1.TJ,SLTR1.TK>,$
                MEAS/IJK,<SLTR1.I,SLTR1.J,SLTR1.K>,$
                DIAMETER/30+V2,30+V2
    
  • After reviewing a sample script to change global settings in the program I found that I also switch to using drop down list instead of radio buttons. Also, I haven't had any luck figuring out how to make the drop down list of choices change right after I make my selection from the other drop down list.
    Cool Generic script dialog. I have started one as well . But only to create just a generic point.
  • Well, a bit more fiddling (and redesign under the hood) has given me a 'working' script to generate GENERIC features. Also got rid of all the PutText() calls, so the only translation needed is the dialog itself (and supporting data in the program). Slots are not completely handled (ignoring IJK2), but who cares?

    The code is free to (ab)use, but I won't guarantee anything, neither functionality nor support. This is mainly an example of an advanced dialog in PC-DMIS BASIC, with things happening while the dialog is running, fields turned on and off, selections filling in data in fields, etc.

    The program is too large to show in a CODE tag, so I'll just outline some of the important points, and attach a ZIP file.

    The major magic in the dialog definition is the adding of a function name at the end of the first line. This function is called (automatically) every time something important happens when the dialog is active. It can be named Whatever, but I choose to call it Events. As long as the result of the function is not zero, the dialog will continue to be active.

    Do note that using the dialog editor (separate program mentioned in other posts) drops the function name from the definition, so each time the dialog editor has been used you have to remember to put the text back again :-(

    Begin Dialog DLGGENFEAT -1,46, 260, 242, "Construct Generic Feature",[B] .Events[/B]
      Text 4,4,61,12, "Feature name:"
      TextBox 68,4,112,12, .edFeatName
      OptionGroup .GRPFEATURE
        OptionButton 8,40,37,12, "Point"
        OptionButton 8,56,37,12, "Plane"
        .
        .
        .
    End Dialog
    


    The rest of the magic is in the Events() function. I'll show it in full, in all it's gory (no, I didn't misspell glory!) details, keeping the comments I wrote during experimenting!

    Function Events(ControlID$, Action%, SuppValue%)
      Events = 99 ' Don't Close Dialog, just continue
        '
       Select Case Action%
        '
        Case 1  '  Before Dialog is visible, hide some controls ("Point" assumed)
            '
            DlgEnable "lbOutIn", 0
            DlgVisible "lbOutIn", 0
            DlgEnable "edAngle", 0
            DlgEnable "edDistance", 0
            DlgEnable "edRadDiam", 0
            DlgEnable "edBoth", 0
            DlgEnable "edValueRef", 0
        '
        Case 2  '  Button pushed, checkbox checked, etc. ControlID$, SuppValue%
             '
             ' For some reason, the radio buttons 'Name' starts With a quote character!?
            If Left(ControlID$, 1) = chr(34) Then
              ' Radio button, but which one? There's no way To Get the group Name, so we have To check the actual text If we have more than one
              ' group, And we can't actually differentiate If two groups have the same text somewhere :-(
              '
              ' Solution: Eliminate all radio groups but one, making combo boxes of the others - done!
              '
              ' activate/deactivate appropriate fields, depending On which radio button was clicked
              '
              FeatureType = SuppValue%
              Select Case FeatureType
              '
                Case 0, 1  '  Point, Plane
                  DlgVisible "lbOutIn", 0
                  DlgEnable "lbOutIn", 0
                  DlgEnable "edAngle", 0
                  DlgEnable "edDistance", 0
                  DlgEnable "edRadDiam", 0
                '
                Case 2  '  Line
                  DlgVisible "lbOutIn", 0
                  DlgEnable "lbOutIn", 0
                  DlgEnable "edAngle", 0
                  DlgEnable "edDistance", 1
                  DlgEnable "edRadDiam", 0
                '
                Case 3  '  None
                  DlgVisible "lbOutIn", 0
                  DlgEnable "lbOutIn", 0
                  DlgEnable "edAngle", 1
                  DlgEnable "edDistance", 1
                  DlgEnable "edRadDiam", 1
                '
                Case 4, 5  '  Circle, Sphere
                  DlgVisible "lbOutIn", 1
                  DlgEnable "lbOutIn", 1
                  DlgEnable "edAngle", 0
                  DlgEnable "edDistance", 0
                  DlgEnable "edRadDiam", 1
                '
                Case 6  '  Cylinder
                  DlgVisible "lbOutIn", 1
                  DlgEnable "lbOutIn", 1
                  DlgEnable "edAngle", 0
                  DlgEnable "edDistance", 1
                  DlgEnable "edRadDiam", 1
                '
                Case 7, 8  '  Round slot, Square slot
                  DlgVisible "lbOutIn", 1
                  DlgEnable "lbOutIn", 1
                  DlgEnable "edAngle", 0
                  DlgEnable "edDistance", 1
                  DlgEnable "edRadDiam", 1
                '
                Case 9  '  Cone
                  DlgVisible "lbOutIn", 1
                  DlgEnable "lbOutIn", 1
                  DlgEnable "edAngle", 1
                  DlgEnable "edDistance", 1
                  DlgEnable "edRadDiam", 0
                '
              End Select
                '
            Elseif  Left(ControlID$, 2) = "lb" Then
              '
              If ControlID$ = "lbSelFeatCoord" Then ' Copy the selected feature name to the edit boxes
                '
                ' feature coordinate selection list
                '
                SelFeatCoordID = FeatureList(SuppValue% + 1)
                DlgText "edX", SelFeatCoordID + ".X"
                DlgText "edY", SelFeatCoordID + ".Y"
                DlgText "edZ", SelFeatCoordID + ".Z"
                '
                ' Use the same feature for IJK, for now...
                '
                SelFeatVectID = SelFeatCoordID
                DlgText "edI", SelFeatVectID + ".I"
                DlgText "edJ", SelFeatVectID + ".J"
                DlgText "edK", SelFeatVectID + ".K"
                '
              ElseIf ControlID$ = "lbSelFeatVect" Then        ' ...unless someone clicked the other selection list
                '
                ' feature vector selection list
                '
                SelFeatVectID = FeatureList(SuppValue% + 1)
                DlgValue "lbValueRef", 2
                DlgText "edI", SelFeatVectID + ".I"
                DlgText "edJ", SelFeatVectID + ".J"
                DlgText "edK", SelFeatVectID + ".K"
                '
              Else
                '
                ' other listboxes And comboboxes, Nothing To Do now - values may be Read later when generating
                '
              End If
              '
            Else ' buttons
              '
              ' Note: ControlID$ is wrong For buttons!!! And we need To check edFeatName If OK pressed
              '
              If ControlID$ = "Cancel" Then ' Yes, this is the OK button !!!
                If DlgText("edFeatName") <> "" Then
                  Events = 0  '  OK To leave
                Else
                  MsgBox "You must enter a name for the feature!"
                End If
              Else
                Events = 0 ' Leave Dialog,
              End If
              '
            End If
        '
        Case 3  '  Change detected (Help doesn't seem To be correct here - gets called directly when a character changes In an Edit box)
            If Left(ControlID$, 2) = "ed" Then
              ' Nothing To Do
            Else
              ' Nothing To Do - don't even know what events would Get here...
            End If
        '
        Case 4  '  Focus change, ControlID$ tells which control will Get focused, SuppValue% numid of control losing it. No MsdgBox Or Dlg here!
            ' don't know what use it can have...
            FocusedControl = ControlID$
            LastFocus = SuppValue%
            ' DlgText "edFeatName", ControlID$+",  "+ Str$(SuppValue%)            ' debug
      End Select
      '
    End Function
    


    Enjoy!

    Attached Files
  • I take that as confirmation that I should stop trying...
    Thanks!