hexagon logo

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.
Parents
  • I dug a little deeper and found that -276 = "Yes" and -287 = "No". You can generate a list with the code below which creates the commands in the Edit Window. Running will give you a report with the number/string pairs. Don't know how long this list is (I stopped at 1000). This negative loop is for "strings.dll".
    Sub GetSettingLangStr()
        Dim oApp As PCDLRN.Application
        Dim oPart As PCDLRN.PartProgram
        Dim oCmds As PCDLRN.Commands
        Dim oCmd As PCDLRN.Command
        Dim i As Long
        Dim bRet As Boolean
        Dim sStr As String
        Dim Result As Variant
        
        On Error GoTo ErrCatcher
        
        Set oApp = CreateObject("PCDLRN.Application")
        Set oPart = oApp.ActivePartProgram
        Set oCmds = oPart.Commands
        
        oApp.Visible = False
        For i = -1 To -1000 Step -1
            
            Set oCmd = oCmds.Add(ASSIGNMENT, True)
            oCmd.Marked = True
            bRet = oCmd.PutText("V4", DEST_EXPR, 0)
            sStr = "GETSETTING(" & Chr(34) & "LangStr(" & i & ")" & Chr(34) & ")"
            bRet = oCmd.PutText(sStr, SRC_EXPR, 0)
            
            Set oCmd = oCmds.Add(SET_COMMENT, True)
            oCmd.Marked = True
            bRet = oCmd.PutText("", ID, 0)
            bRet = oCmd.SetToggleString(2, COMMENT_TYPE, 0)
            sStr = Chr(34) & i & ":   " & Chr(34)
            bRet = oCmd.PutText(sStr, COMMENT_FIELD, 1)
            sStr = Chr(34) & i & ":   " & Chr(34) & "+V4"
            Result = oCmd.SetExpression(sStr, COMMENT_FIELD, 1)
            
        Next i
        oApp.Visible = True
        oPart.RefreshPart
        
    ExitSub:
        Set oCmd = Nothing
        Set oCmds = Nothing
        Set oPart = Nothing
        Set oApp = Nothing
        Exit Sub
    ErrCatcher:
        MsgBox ("Error: " & Err.Number & vbCrLf & "Description: " & Err.Description)
        On Error GoTo 0
        Resume ExitSub
    End Sub
Reply
  • I dug a little deeper and found that -276 = "Yes" and -287 = "No". You can generate a list with the code below which creates the commands in the Edit Window. Running will give you a report with the number/string pairs. Don't know how long this list is (I stopped at 1000). This negative loop is for "strings.dll".
    Sub GetSettingLangStr()
        Dim oApp As PCDLRN.Application
        Dim oPart As PCDLRN.PartProgram
        Dim oCmds As PCDLRN.Commands
        Dim oCmd As PCDLRN.Command
        Dim i As Long
        Dim bRet As Boolean
        Dim sStr As String
        Dim Result As Variant
        
        On Error GoTo ErrCatcher
        
        Set oApp = CreateObject("PCDLRN.Application")
        Set oPart = oApp.ActivePartProgram
        Set oCmds = oPart.Commands
        
        oApp.Visible = False
        For i = -1 To -1000 Step -1
            
            Set oCmd = oCmds.Add(ASSIGNMENT, True)
            oCmd.Marked = True
            bRet = oCmd.PutText("V4", DEST_EXPR, 0)
            sStr = "GETSETTING(" & Chr(34) & "LangStr(" & i & ")" & Chr(34) & ")"
            bRet = oCmd.PutText(sStr, SRC_EXPR, 0)
            
            Set oCmd = oCmds.Add(SET_COMMENT, True)
            oCmd.Marked = True
            bRet = oCmd.PutText("", ID, 0)
            bRet = oCmd.SetToggleString(2, COMMENT_TYPE, 0)
            sStr = Chr(34) & i & ":   " & Chr(34)
            bRet = oCmd.PutText(sStr, COMMENT_FIELD, 1)
            sStr = Chr(34) & i & ":   " & Chr(34) & "+V4"
            Result = oCmd.SetExpression(sStr, COMMENT_FIELD, 1)
            
        Next i
        oApp.Visible = True
        oPart.RefreshPart
        
    ExitSub:
        Set oCmd = Nothing
        Set oCmds = Nothing
        Set oPart = Nothing
        Set oApp = Nothing
        Exit Sub
    ErrCatcher:
        MsgBox ("Error: " & Err.Number & vbCrLf & "Description: " & Err.Description)
        On Error GoTo 0
        Resume ExitSub
    End Sub
Children
No Data