IF_GOTO/C1.INPUT and multiple languages...

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

  • IF_GOTO/C1.INPUT and multiple languages...

    OK, I'm stumped (not really, but I would like a general solution).

    If I have an IF_GOTO/C1.INPUT == "YES" in my program, it will break when I change PC-DMIS to Swedish.

    So, I can write IF_GOTO/(C1.INPUT == "YES") or (C1.INPUT == "JA") to make it work in English and Swedish (and some more, like German).

    But how do I write to have it work in the current language PC-DMIS is set to, whatever language that is?

    In the Report Editor there's a function LOADSTR(xyz) which can get the current translation of string #xyz, but that doesn't work in a part program.
    AndersI
    SW support - Hexagon Metrology Nordic AB

  • #2
    The question is very relevant and current.

    There must be a resource string somewhere you can use?
    Something like IF_GOTO/C1.INPUT == RESSTR(47) with RESSTR(47) in this case is "YES" in whatever language PC-DMIS is running currently.
    Maybe there's a list of these resource strings?
    PC-DMIS CAD++ 2o19 R1 SP6

    Comment


    • #3
      Well, the LOADSTR() function already exists, but it only works in the Report Editor - why not just make that one available in part programs too, and document the most important numbers?

      Quoting the Help:

      Loading Strings from PC-DMIS

      Similar to how you can change the text color for a cell in the "Changing Expression Text Color" topic, the Reporting expression language lets you pull strings from PC-DMIS's current running language by using this expression:

      =LOADSTR(<integer expression>)

      This function takes a single parameter, an integer number that corresponds to the value of a string located in resource.dll or strings.dll.

      A positive number pulls the string from the resource.dll file.

      A negative number pulls the string from the strings.dll file.

      If you type this function in the Cell Expression box (or cell) of the GridControlObject, click OK, and then click outside of the object. PC-DMIS evaluates the expression and returns the string assigned to the specified integer value.



      As a sidetrack, I found this [very] hackish solution, which relies on the two words "YES" and "NO" existing in the right place in the COMMENT/YESNO command (FULL_SCREEN=NO, AUTO-CONTINUE=YES):

      Code:
      C1         =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=YES,TIME DELAY=0,
                  Svara JA eller NEJ!
                  IF_GOTO/C1.INPUT==GETTEXT(185, 0, {C1}),GOTO = SVAR_NEJ
                  IF_GOTO/C1.INPUT==GETTEXT(450, 0, {C1}),GOTO = SVAR_JA
                  COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                  Du svarade något annat än "JA" eller "NEJ"
                  GOTO/****
      SVAR_JA    =LABEL/
                  COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                  Du svarade "JA"
                  GOTO/****
      SVAR_NEJ   =LABEL/
                  COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                  Du svarade "NEJ"
                  GOTO/****
      ****       =LABEL/
      Last edited by AndersI; 05-27-2014, 11:23 AM.
      AndersI
      SW support - Hexagon Metrology Nordic AB

      Comment


      • #4
        Hey, that's pretty creative. You could call it hackish or you could call it making the most of available resources!
        2013MR1 SP6
        Global Frames, Tesastar-M Heads, LSP-X1M/H Probes

        Comment


        • #5
          Originally posted by DaSalo View Post
          Hey, that's pretty creative. You could call it hackish or you could call it making the most of available resources!
          Frugal programming , very nice!

          Coffee's working this AM, eh?

          TK
          sigpicHave a homebrew

          Comment


          • #6
            Try tis it should work in any language.


            ASSIGN/V1="YES"
            ASSIGN/V2="NO"

            C1 =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
            ASK YOUR QUESTION

            IF/C1.INPUT==V1
            GOTO/L1
            END_IF/
            IF/C1.INPUT==V2
            GOTO/L2
            END_IF/

            Comment


            • #7
              Unfortunately not, as /YESNO returns the text JA/NEJ in Swedish, not YES/NO. If it had only returned 1/0 instead, everything had been good.
              AndersI
              SW support - Hexagon Metrology Nordic AB

              Comment


              • #8
                Try this (you have to use INPUT type of comment):

                C1 =COMMENT/INPUT,NO,FULL SCREEN=NO,
                Svara JA eller NEJ!
                1-YES (JA), 2-NO (NEJ)

                IF_GOTO/C1.INPUT=1,GOTO = SVAR_JA
                IF_GOTO/C1.INPUT=2,GOTO = SVAR_NEJ
                COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                Du svarade något annat än "JA" eller "NEJ"
                GOTO/****
                SVAR_JA =LABEL/
                COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                Du svarade "JA"
                GOTO/****
                SVAR_NEJ =LABEL/
                COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                Du svarade "NEJ"
                GOTO/****
                **** =LABEL/

                Comment


                • #9
                  Thanks - yes, I know that; my main point was that PC-DMIS has a standard YES/NO question that works in all languages, but the returned result is language specific and there is no standard way to get the language specific "YES" and "NO" strings to compare with, making the YES/NO dialog worthless when your installation has more than one language available (and every non-English installation also has English available).

                  If only the YES/NO dialog had returned the same strings irrespective of the current language (for example "YES"/"NO" or "1"/"0") all had been well...
                  AndersI
                  SW support - Hexagon Metrology Nordic AB

                  Comment


                  • #10
                    Maybe this is more work than it's worth, but what about using the Form Editor to create a form with bilingual instructions. I'm thinking two text boxes side by side, English/Swedish. The user input can be done with Radio Buttons. RadioButton1.Text="Yes/Ja" , RadioButton2.text="No/Nej".

                    Then when the form closes, your flow controls will rely on the value of the RadioButton selection (1 or 2).

                    Comment


                    • #11
                      I'm sure the original intention was to have an accommodation that was useful for any language installation, not one that is specifically derived on one. Like stated, instead of a yes/no function pulling the respected "YES" or "NO" based on the current language to be comparable to a universal string of "YES"/"NO" or a 1 or 0, or a 1 or 2. We are left with language specific answers that have to be compared to language specific strings.

                      If I understand this correctly.

                      Comment


                      • #12
                        Code:
                        $$ NO,
                                    Initialise B_RES (aka Boolean Result)
                                    ASSIGN/B_RES=0
                        C1         =COMMENT/YESNO,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                                    Is NinjaBadger a genius?
                        $$ NO,
                                    Get the comment type (i.e. YESNO) as a string
                                    ASSIGN/COMTYPE=GETTEXT(190,0,{C1})
                        $$ NO,
                                    IF left part of that (as long as the number of charachters in the result) = the user selection, then it's a YES
                                    IF/LEFT(COMTYPE,LEN(C1.INPUT))==C1.INPUT
                                    ASSIGN/B_RES=1
                                    END_IF/
                                    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
                                    B_RES

                        I'm making the assumption it's always YESNO in that order, i.e. it's not NONOUI in French or something daft.

                        Now we can have a boolean 1/0 result instead of a language specific!


                        Edited as I realised I didn't need to use GETCOMMAND (YESNO command has an ID)
                        Also I'd used "Comment Type" (language specific) as an argument for gettext instead of 190
                        Last edited by NinjaBadger; 12-16-2014, 10:12 AM.
                        Automettech - Automated Metrology Technology

                        Comment


                        • #13
                          NinjaBadger, that's a quite beautiful solution - although more or less the same approach as I took in my 'hackish' solution!

                          I can see two problem with yours, though - if a language has a word for NO beginning with the word for YES (as in YES and YESNOT), or if the PC-DMIS translation calls the function ASK_FOR_YES_OR_NO in some language...

                          (none of them apply to my hack)
                          AndersI
                          SW support - Hexagon Metrology Nordic AB

                          Comment


                          • #14
                            Originally posted by AndersI View Post
                            NinjaBadger, that's a quite beautiful solution - although more or less the same approach as I took in my 'hackish' solution!

                            I can see two problem with yours, though - if a language has a word for NO beginning with the word for YES (as in YES and YESNOT), or if the PC-DMIS translation calls the function ASK_FOR_YES_OR_NO in some language...

                            (none of them apply to my hack)
                            I understand your first point can you explain the second point a bit more?
                            Automettech - Automated Metrology Technology

                            Comment


                            • #15
                              I meant that the YESNO part of COMMENT/YESNO ... is available for translator abuse - it could be translated to something similar to COMMENT/ASK_FOR_YES_OR_NO ... and your code would match "ASK" or "AS"...
                              AndersI
                              SW support - Hexagon Metrology Nordic AB

                              Comment

                              Related Topics

                              Collapse

                              Working...
                              X