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

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?
    AndersI
    SW support - Hexagon Metrology Nordic AB

  • #2
    Can you post a example of the basic code Andersl?

    Comment


    • AndersI
      AndersI commented
      Editing a comment
      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...

    • davehocum
      davehocum commented
      Editing a comment
      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.

  • #3
    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
    Last edited by InspectorJester; 08-02-2018, 12:35 PM.

    Comment


    • #4
      Don't give up!
      PcDmis 2015.1 SP10 CAD++
      Global 7-10-7 DC800S

      Comment


      • AndersI
        AndersI commented
        Editing a comment
        I never give up, although I may change focus...

      • Kp61dude!
        Kp61dude! commented
        Editing a comment
        As it should same here.

    • #5
      Originally posted by davehocum View Post
      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):

      Generic1.PNG

      which would then add the following to the current pp:

      Code:
      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
      Last edited by AndersI; 08-03-2018, 09:09 AM.
      AndersI
      SW support - Hexagon Metrology Nordic AB

      Comment


      • davehocum
        davehocum commented
        Editing a comment
        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.

      • AndersI
        AndersI commented
        Editing a comment
        I take that as confirmation that I should stop trying...
        Thanks!

      • davehocum
        davehocum commented
        Editing a comment
        Now with what I was testing was with Function Enable (Events) without Events = 99. So, don't give up with my situation. Thank you for posting your code. Will try to play with it and see how much I can mess it up. Also, my Function was between my Begin Dialog's.
        Last edited by davehocum; 08-03-2018, 12:13 PM.

    • #6
      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 :-(

      Code:
      Begin Dialog DLGGENFEAT -1,46, 260, 242, "Construct Generic Feature", .Events
        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!

      Code:
      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
      Last edited by AndersI; 08-03-2018, 10:56 AM.
      AndersI
      SW support - Hexagon Metrology Nordic AB

      Comment


      • Kp61dude!
        Kp61dude! commented
        Editing a comment
        Thank you @Andersl you're the man!

    • #7
      Anders,

      Can you explain to me why you even want to use advanced dialogs? What can they do that Forms can't do more easily?

      Thanks
      Automettech - Automated Metrology Technology

      Comment


      • #8
        Originally posted by NinjaBadger View Post
        Can you explain to me why you even want to use advanced dialogs? What can they do that Forms can't do more easily?
        Well, I'm like the mountain climber - "Because it's there!". And, as I said in the first post:

        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
        Being Software Support means I have to answer questions, and to do that I need the answers myself. Sometimes the answer will be "Don't do it!", which is the direction this question goes for the moment...

        Additionally, I'm not a big fan of Forms, where you need to learn yet another variant of [not very documented] Basic if you want to do something fancy. To be honest, neither Forms nor PCD Basic will be my choice if I have the power to choose - it will be my faithful [Borland] Delphi 5.0 (Or Delphi X if the customer wants it to look 'modern'), as I can whip up a mockup for discussions in ten minutes, and a complete, working, fancy dialog/form, with error handling, default values, and everything (including the kitchen sink!) in an hour or two, with that tool (it takes a bit longer with the Delphi X, that's why I prefer the old 5.0). Making the dialogs/forms as 3:rd party .exe files also means that I can run with PC-DMIS completely hidden, if need be.
        Last edited by AndersI; 08-07-2018, 06:52 AM.
        AndersI
        SW support - Hexagon Metrology Nordic AB

        Comment


        • #9
          Fair enough. I was just asking in case I'd missed something that these dialogs offered which Froms didn't.
          Automettech - Automated Metrology Technology

          Comment


          • #10
            Andersl,
            Do you have a safe link to download the Delphi 5.0?

            Comment


            • AndersI
              AndersI commented
              Editing a comment
              Not Delphi 5.0, no. The current offering (free Community Edition) is at https://www.embarcadero.com/products/delphi/starter but I haven't tried it (I'm perfectly satisfied with D5 and D XE, so stopped buying new versions many years ago).

            • davehocum
              davehocum commented
              Editing a comment
              Thank you for the info Andersl

          • #11
            My favorite Delphi version was 7. Oh, those were the days!

            Nowadays when I have to, I fiddle in .NET, VBS, VBA, VB, C (Arduino) and PCDBasic...
            PC-DMIS CAD++ 2o18 R2 SP3

            Comment

            Related Topics

            Collapse

            Working...
            X