hexagon logo

Data from script to dc dmis

Hello,

My target is to create unique number for every single report, number should be in a format 00000. Script should read this number from .txt file, then increase by 1 and add text "Report no.: ". Final result should be: like "Report no.: 0015". I have script:

[Sub Main

Dim App As Object
Set App = CreateObject ("PCDLRN.Application")
Dim Text As String
Dim Part As Object
Set Part = App.ActivePartProgram
Dim RepNo As String
Dim No As Integer
Dim V100 As Object
Set V100 = part.getvariablevalue ("V100")

Open "X:\CMM_Data\Proven programs\SCRIPT\REPORTNO.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, No
Loop
Close #1

No=No+1

If No>9999Then
Set Text = "Report no.: "
End If
If No>999 Then
Set Text = "Report no.: 0"
End If
If No>99 Then
Set Text = "Report no.: 00"
End If
If No>9 Then
Set Text = "Report no.: 000"
End If
If No<=9 Then
Set Text = "Report no.: 0000"
End If
'MsgBox Text
'MsgBox No

RepNo = Text & No

MsgBox RepNo

PART.SetVariableValue "V100", RepNo

Part.RefreshPart


End Sub]

This script giving report number which I want but I can't transfer RepNo (report number) to pc dmis, pc dmis showing massage "Runtime error on line: 43 - type mismatch". line 43: "PART.SetVariableValue "V100", RepNo" I did try the way of tries and mistakes but no result achieved. Can please any one tel me what is the problem with this script?


Code in Pc dmis:
[ASSIGN/100="REPORT NO.: 0001"
CS3 =SCRIPT/FILENAME= C:\USERS\DMILIUS\DESKTOP\DELETE\TEST.BAS
FUNCTION/Main,SHOW=NO,,
STARTSCRIPT/
COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
V100]

Regards
Parents
  • RepNo = Text & No

    MsgBox RepNo

    V100.StringValue = RepNo

    PART.SetVariableValue "V100", V100

    Part.RefreshPart


    Also your logic for the string generation is wrong.

    If No>9999Then
    Set Text = "Report no.: "
    End If
    If No>999 Then
    Set Text = "Report no.: 0"
    End If
    If No>99 Then
    Set Text = "Report no.: 00"
    End If
    If No>9 Then
    Set Text = "Report no.: 000"
    End If
    If No<=9 Then
    Set Text = "Report no.: 0000"
    End If


    You need to reverse the order of the if statements.

    If No<=9 Then
    Set Text = "Report no.: 0000"
    End If
    If No>9 Then
    Set Text = "Report no.: 000"
    End If
    If No>99 Then
    Set Text = "Report no.: 00"
    End If
    If No>999 Then
    Set Text = "Report no.: 0"
    End If
    If No>9999Then
    Set Text = "Report no.: "
    End If



Reply
  • RepNo = Text & No

    MsgBox RepNo

    V100.StringValue = RepNo

    PART.SetVariableValue "V100", V100

    Part.RefreshPart


    Also your logic for the string generation is wrong.

    If No>9999Then
    Set Text = "Report no.: "
    End If
    If No>999 Then
    Set Text = "Report no.: 0"
    End If
    If No>99 Then
    Set Text = "Report no.: 00"
    End If
    If No>9 Then
    Set Text = "Report no.: 000"
    End If
    If No<=9 Then
    Set Text = "Report no.: 0000"
    End If


    You need to reverse the order of the if statements.

    If No<=9 Then
    Set Text = "Report no.: 0000"
    End If
    If No>9 Then
    Set Text = "Report no.: 000"
    End If
    If No>99 Then
    Set Text = "Report no.: 00"
    End If
    If No>999 Then
    Set Text = "Report no.: 0"
    End If
    If No>9999Then
    Set Text = "Report no.: "
    End If



Children
  • Thanks for help,
    By using your first suggestion I did overcome this problem.
    About "logic for the string generation" as i see I'm still struggle to think in more complex way.
    Regards
    Finished code of stage:
    [Sub Main

    Dim App As Object
    Set App = CreateObject ("PCDLRN.Application")
    Dim Text As String
    Dim Part As Object
    Set Part = App.ActivePartProgram
    Dim No As Integer
    Dim V100 As Object
    Set V100 = part.getvariablevalue ("V100")

    Open "X:\CMM_Data\Proven programs\SCRIPT\REPORTNO.txt" For Input As #1
    Do While Not EOF(1)
    Line Input #1, No
    Loop
    Close #1

    No=No+1

    If No>9999Then
    Text = "Report no.: "
    Else
    If No>999 Then
    Text = "Report no.: 0"
    Else
    If No>99 Then
    Text = "Report no.: 00"
    Else
    If No>9 Then
    Text = "Report no.: 000"
    Else
    If No<=9 Then
    Text = "Report no.: 0000"
    End If
    End If
    End If
    End If
    End If

    RepNo = Text & No

    'MsgBox RepNo

    V100.StringValue = RepNo

    PART.SetVariableValue "V100", V100

    Part.RefreshPart
    End Sub]