hexagon logo

Need help with my script

First i hope you will excuse my programming skills. Its been 17 years since i learned programming in Java, so this code i made here is parts from other people's programs i put togther for this.

Most of my program work, and do what is was intended for.

My current problem is that when i try to make a string "PRINT_PATH" with information where to save my report.
Then it does not get used in my Print command part. Seems that the PRINT_PATH only have a "0" and not the prober path i made in my script.

Hope this make any sence Slight smile


LØBENR2 =COMMENT/INPUT,NO,'Løbenr.'
ORDRENR2 =COMMENT/INPUT,NO,'Ordrenr.'
ASSIGN/LØBENR1=STR(LØBENR2.INPUT)
ASSIGN/ORDRE1=ORDRENR2.INPUT
ASSIGN/EMNE1="7427270"
ASSIGN/REVISION1="2"
Test_samle =SCRIPT/FILENAME= M:\SCRIPT\SAMLESCRIPT.BAS
FUNCTION/Main,SHOW=YES,ARG1=REVISION1,ARG2=LØBENR1,ARG3=EMNE1,ARG4=ORDRE1,,
STARTSCRIPT/
C1000 =COMMENT/INPUT,NO,'Initialer'
ASSIGN/INI=C1000.INPUT
ASSIGN/PRINT_PATH="O:\QA\TEST\PRL05555\7427270_2_MP_5555-.PDF"
ENDSCRIPT/
$$ NO,***************************** Statestik *************************************************
STATS/OFF
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; : EMNE1.INPUT
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; : REVISION1.INPUT
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; : STR(LØBENR1.INPUT)
TRACEFIELD/NO_DISPLAY,LIMIT=25 ; Ordre : ORDRENR2.INPUT
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; PROCESS : CTP
TRACEFIELD/NO_DISPLAY,LIMIT=15 ; Initialer : STR(INI)
$$ NO,********************************** Sættes ind i ende af program ******************
PRINT/REPORT,EXEC MODE=END,$
TO_FILE=ON,AUTO=PRINT_PATH,$
TO_PRINTER=OFF,$
TO_DMIS_REPORT=OFF,FILE_OPTION=OVERWRITE,FILENAME=,$
REPORT_THEORETICALS=ALL,REPORT_FEATURE_WITH_DIMENSIONS=YES,$
PREVIOUS_RUNS=DELETE_INSTANCES

Sub main(REVISION1 As String, LØBENR1 As String, EMNE1 As String, ORDRE1 As String) 'bring newpn In As ARG1 from PCDMIS
Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object


Set DmisApp = CreateObject("PCDLRN.Application")
Set DmisPart = DmisApp.ActivePartProgram
Set DmisCommands = DmisPart.Commands
CommandCount = DmisCommands.Count
Set DmisCommand = DmisCommands.Item(CommandCount)
DmisCommands.InsertionPointAfter DmisCommand

Dim C1000
' Set C1000 = "" A Null String
C1000 = ""

Set DmisCommand = DmisCommands.Add(SET_COMMENT, True)
DmisCommand.Marked = True

retval = DmisCommand.PutText ("C1000", ID, 0)
retval = DmisCommand.SetToggleString (3, COMMENT_TYPE, 0)
retval = DmisCommand.PutText ("Initialer", COMMENT_FIELD, 1)
retval = DmisCommand.SetToggleString (1, OUTPUT_TYPE, 0)

Set DmisCommand = DmisCommands.Add(ASSIGNMENT, True)
DmisCommand.Marked = True
retval = DmisCommand.PutText ("INI", DEST_EXPR, 0)
retval = DmisCommand.PutText ("C1000.INPUT", SRC_EXPR, 0)

Dim PARTNAME2 As String
PARTNAME2 = EMNE1 + "_" + REVISION1 + "_MP_" + LØBENR1

Dim JOB_PATH As String
JOB_PATH = "O:\QA\TEST"
Dim REPORT_PATH1 As String
REPORT_PATH1 = JOB_PATH + "" + ORDRE1
Dim REPORT_PATH2 As String
REPORT_PATH2 = REPORT_PATH1 + ""
Dim REPORT_NAME As String
REPORT_NAME = PARTNAME2 + "-"
Dim PRINT_PATH1
PRINT_PATH1 = """" + REPORT_PATH2 + REPORT_NAME + ".PDF" + """"

Set DmisCommand = DmisCommands.Add(ASSIGNMENT, True)
DmisCommand.Marked = True

retval = DmisCommand.PutText ("PRINT_PATH", DEST_EXPR, 0)
retval = DmisCommand.PutText (PRINT_PATH1, SRC_EXPR, 0)

DmisPart.PARTNAME=PARTNAME2 'make the new control number, the part number
DmisPart.SERIALNUMBER=LØBENR1
DmisPart.REVISIONNUMBER=REVISION1
DmisPart.statscount=PROCESS1
DmisPart.refreshpart
DmisPart.save ' save the part program so it has the latest part number
Dim repwin As Object
Set repwin = DmisPart.reportwindow
repwin.refreshreport 'refresh report; now the report shows the latest part number.

On Error Resume Next
MkDir REPORT_PATH1

End Sub
  • Had to change my solution. Had to make input window in the script, else i could not make my content check work.

    So this is the simple solution for me.

    Label1:
    
    Begin Dialog DIALOG_1 16,16, 118, 64, "Initials"
      OKButton 12,40,37,12
      CancelButton 60,40,37,12
      TextBox 12,16,84,16, .EditBox_1
      Text 12,4,84,12, "Enter your Initials"
    End Dialog
    
    Dim Dialg As DIALOG_1
    
    button1 = Dialog(Dialg)
    
    If button1 = 0 Then
      Progtype= "END"
    Else
    
    Dim INI As String
      INI = Dialg.EditBox_1 
    Dim TestIni As Integer 
      TestIni = Len(INI)
    
      If INI = "" Then        
          GoTo Label1
      End If 
    
      If TestIni < 2 Then  
          GoTo Label1
      End If
    
      If TestIni > 3 Then
          GoTo Label1
      End If
    
    End If
    
    


    Is it posible to make input field active, so you dont have to use mouse or tab to make active?

    Can you make a script cancel a PC dmis program if you press cancel in window?
  • I have tried to use the SetFocus command (don't know the exact wording for it in CypressEnable) but never got that to work...

    Set a label at the very end of your program (the last command) and have the script jump to that label if the user press cancel?
  • The return code of the Dlg() function is zero (0) when you press a CancelButton to close the dialog.

    PartProgram.CancelExecution would be my first guess, but I haven't tried it, just guessing from the type library.
    There's also ExecutionWindow.CancelExecution and CommentInputDialog.PressCancelButton, but I guess that they only work when the respective dialog is open.