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?
Parents
  • 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
Reply Children
No Data