hexagon logo

Custom Comment Script, upgraded

I have a version of this script hooked to a custom icon so with one-click I can run it and add comments quickly, or add canned (standadized) comments quickly.

Credit goes to Nate on the other forum.

I've modified it 10,000 times to suit my whims of whatever silly text character strings I like to add. My personal version has 13 different canned $$ comments.

One thing I noticed that could be construed as a bug:
If in your PC-DMIS program you have a $$ comment that you want to show on the report, you may toggle it from NO to YES.

However once you do that, any subsequent $$ comments you add with the BAS all default to YES display on the report.

So I fixed it.

Also new is a Form Feed checkbox to space your report out alot.

'Custom Comment Script
Sub Main()

Dim buttonval As Integer

Dim App As Object
Set App = CreateObject("PCDLRN.Application")

Dim Part As Object
Set Part = App.ActivePartProgram

Dim Cmds As Object
Set Cmds = Part.Commands

Dim PartProg As Object
Set PartProg = App.ActivePartProgram

Dim Cmd As Object

Begin Dialog DLG_REPORT_COMMENT 50, 32, 290, 300, "What Comments Do You Need?"


OKButton 225, 175, 50, 25



CheckBox 12, 10, 150, 8, "$$ THAT COMMENT YOU ALWAYS USE", .CheckBox1

CheckBox 205, 10, 60, 8, "FORM FEED", .CheckBox13


Text 12, 35, 120, 8, "Custom $$ Comment:"
TextBox 15, 45, 180, 12, .EditBox13
TextBox 15, 55, 180, 12, .EditBox14
TextBox 15, 65, 180, 12, .EditBox15

Text 12, 85, 125, 8, "Custom Report Comment:"
TextBox 15, 95, 180, 12, .EditBox1
TextBox 15, 105, 180, 12, .EditBox2
TextBox 15, 115, 180, 12, .EditBox3

Text 12, 135, 125, 8, "Custom Operator Comment:"
TextBox 15, 145, 180, 12, .EditBox23
TextBox 15, 155, 180, 12, .EditBox24
TextBox 15, 165, 180, 12, .EditBox25
TextBox 15, 175, 180, 12, .EditBox26
TextBox 15, 185, 180, 12, .EditBox27
TextBox 15, 195, 180, 12, .EditBox28

End Dialog

'-------------------------------------------------------------------------------------------------------

Dim dlg1 As DLG_REPORT_COMMENT
buttonval = Dialog(dlg1)
If button1 = 0 Then

Dim customstr1 As String
customstr1 = dlg1.EditBox1
Dim lenstr1 As Integer
lenstr1 = Len(dlg1.EditBox1)

Dim customstr2 As String
customstr2 = dlg1.EditBox2
Dim lenstr2 As Integer
lenstr2 = Len(dlg1.EditBox2)

Dim customstr3 As String
customstr3 = dlg1.EditBox3
Dim lenstr3 As Integer
lenstr3 = Len(dlg1.EditBox3)

'

Dim customstr13 As String
customstr13 = dlg1.EditBox13
Dim lenstr13 As Integer
lenstr13 = Len(dlg1.EditBox13)

Dim customstr14 As String
customstr14 = dlg1.EditBox14
Dim lenstr14 As Integer
lenstr14 = Len(dlg1.EditBox14)

Dim customstr15 As String
customstr15 = dlg1.EditBox15
Dim lenstr15 As Integer
lenstr15 = Len(dlg1.EditBox15)

'


Dim customstr23 As String
customstr23 = dlg1.EditBox23
Dim lenstr23 As Integer
lenstr23 = Len(dlg1.EditBox23)

Dim customstr24 As String
customstr24 = dlg1.EditBox24
Dim lenstr24 As Integer
lenstr24 = Len(dlg1.EditBox24)

Dim customstr25 As String
customstr25 = dlg1.EditBox25
Dim lenstr25 As Integer
lenstr25 = Len(dlg1.EditBox25)

Dim customstr26 As String
customstr26 = dlg1.EditBox26
Dim lenstr26 As Integer
lenstr26 = Len(dlg1.EditBox26)

Dim customstr27 As String
customstr27 = dlg1.EditBox27
Dim lenstr27 As Integer
lenstr27 = Len(dlg1.EditBox27)

Dim customstr28 As String
customstr28 = dlg1.EditBox28
Dim lenstr28 As Integer
lenstr28 = Len(dlg1.EditBox28)

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


If dlg1.CheckBox1 = 1 Then
Set Cmd = Cmds.Add(SET_COMMENT, True)
retvaltype = Cmd.PutText("$$", COMMENT_TYPE, 0)
retvaltype = Cmd.SetToggleString (1, OUTPUT_TYPE, 0)
If dlg1.CheckBox1 = 1 Then
retvaltype = Cmd.PutText("THAT COMMENT YOU ALWAYS USE", COMMENT_FIELD, 1)
End If
Cmd.ReDraw
End If


If dlg1.CheckBox13 = 1 Then
Set Cmd = Cmds.Add(PRINT_FORM_FEED, TRUE)
End If


'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If lenstr1 > 0 Then
Set Cmd = Cmds.Add(SET_COMMENT, True)
retvaltype = Cmd.PutText("REPT", COMMENT_TYPE, 0)
retvaltype = Cmd.PutText(customstr1, COMMENT_FIELD, 1)
If lenstr2 > 0 Then
retvaltype = Cmd.PutText(customstr2, COMMENT_FIELD, 2)
End If
If lenstr3 > 0 Then
retvaltype = Cmd.PutText(customstr3, COMMENT_FIELD, 3)
End If
Cmd.ReDraw
End If

If lenstr13 > 0 Then
Set Cmd = Cmds.Add(SET_COMMENT, True)
retvaltype = Cmd.PutText("$$", COMMENT_TYPE, 0)
retvaltype = Cmd.SetToggleString (1, OUTPUT_TYPE, 0)
retvaltype = Cmd.PutText(customstr13, COMMENT_FIELD, 1)
If lenstr14 > 0 Then
retvaltype = Cmd.PutText(customstr14, COMMENT_FIELD, 2)
End If
If lenstr15 > 0 Then
retvaltype = Cmd.PutText(customstr15, COMMENT_FIELD, 3)
End If
Cmd.ReDraw
End If


If lenstr23 > 0 Then
Set Cmd = Cmds.Add(SET_COMMENT, True)
retvaltype = Cmd.PutText("OPER", COMMENT_TYPE, 0)
retvaltype = Cmd.PutText(customstr23, COMMENT_FIELD, 1)
If lenstr24 > 0 Then
retvaltype = Cmd.PutText(customstr24, COMMENT_FIELD, 2)
End If
If lenstr25 > 0 Then
retvaltype = Cmd.PutText(customstr25, COMMENT_FIELD, 3)
End If
If lenstr26 > 0 Then
retvaltype = Cmd.PutText(customstr26, COMMENT_FIELD, 4)
End If
If lenstr27 > 0 Then
retvaltype = Cmd.PutText(customstr27, COMMENT_FIELD, 5)
End If
If lenstr28 > 0 Then
retvaltype = Cmd.PutText(customstr28, COMMENT_FIELD, 6)
End If
Cmd.ReDraw
End If

End If
End Sub





To add a script to a custom icon:
Right-click on toolbar area
Select customize

On left-most tab "Menu", click on Create Item
Use the ... button to navigate to where the BAS is stored
It won't show up - you gotta toggle the Files Of Type to Basic Script
Choose it
Now there's a Change Icon buton too, google free icons there's a bazillion out there.

Now go to Toolbars tab
There click on New then Toolbar
Now you can Add your new Item to your new toolbar from the bottom-most User Defined Commands.

Done.

Profit.
Parents
  • 
    
    '- - - - CUSTOM $$ DOCUMENT COMMENT, no options except "NOTE:" ------------------------------
    If lenstr13 > 0 And dlg1.CheckBoxE36 = 0 And dlg1.CheckBoxE46 = 0 Then
    Set Cmd = Cmds.Add(SET_COMMENT, True)
    retvaltype = Cmd.PutText("$$", COMMENT_TYPE, 0)
    retvaltype = Cmd.SetToggleString (1, OUTPUT_TYPE, 0)
    
     If dlg1.Checkbox7071 = 1 Then
     retvaltype = Cmd.PutText("NOTE: " + customstr13, COMMENT_FIELD, 1)
     End If
    
     If dlg1.Checkbox7071 = 0 And dlg1.CheckBoxE36 = 0 And dlg1.CheckBoxE46 = 0 Then
     retvaltype = Cmd.PutText(customstr13, COMMENT_FIELD, 1)
     End If
    
     If lenstr14 > 0 Then
     retvaltype = Cmd.PutText(customstr14, COMMENT_FIELD, 2)
     End If
    
     If lenstr15 > 0 Then
     retvaltype = Cmd.PutText(customstr15, COMMENT_FIELD, 3)
     End If
    
     If lenstr16 > 0 Then
     retvaltype = Cmd.PutText(customstr16, COMMENT_FIELD, 4)
     End If
    
     If lenstr17 > 0 Then
     retvaltype = Cmd.PutText(customstr17, COMMENT_FIELD, 5)
     End If
    
     If lenstr18 > 0 Then
     retvaltype = Cmd.PutText(customstr18, COMMENT_FIELD, 6)
     End If
    
     If lenstr19 > 0 Then
     retvaltype = Cmd.PutText(customstr19, COMMENT_FIELD, 7)
     End If
    
     If lenstr20 > 0 Then
     retvaltype = Cmd.PutText(customstr20, COMMENT_FIELD, 8)
     End If
    
     If lenstr21 > 0 Then
     retvaltype = Cmd.PutText(customstr21, COMMENT_FIELD, 9)
     End If
    
         If dlg1.Checkbox7072 = 1 Then
          Open "C:\TEMP\NEWCANNED.txt" For Output As #1
          print #1, customstr13
    
           If lenstr14 > 0 Then
           print #1, customstr14
           End If
    
           If lenstr15 > 0 Then
           print #1, customstr15
           End If
    
           If lenstr16 > 0 Then
           print #1, customstr16
           End If
    
           If lenstr17 > 0 Then
           print #1, customstr17
           End If
    
           If lenstr18 > 0 Then
           print #1, customstr18
           End If
    
           If lenstr19 > 0 Then
           print #1, customstr19
           End If
    
           If lenstr20 > 0 Then
           print #1, customstr20
           End If
    
           If lenstr21 > 0 Then
           print #1, customstr21
           End If
    
          Close #1
        End If
    
    Cmd.ReDraw
    End If
    
    
    '''''''''''' NEW CANNED COMMENT !$%%$^&#*^@%^!$%~%%^@^&^@$&*()_$*~!%!^% '''''''''''
          If dlg1.Checkbox7073 = 1 Then
    Dim Line1 As String
    Dim Line2 As String
    Dim Line3 As String
    Dim Line4 As String
    Dim Line5 As String
    Dim Line6 As String
    Dim Line7 As String
    Dim Line8 As String
    Dim Line9 As String
    
          Open "C:\TEMP\NEWCANNED.txt" For Input As #1
          Line Input #1, Line1
          Line Input #1, Line2
          Line Input #1, Line3
          Line Input #1, Line4
          Line Input #1, Line5
          Line Input #1, Line6
          Line Input #1, Line7
          Line Input #1, Line8
          Line Input #1, Line9
          Close #1
    
    Set Cmd = Cmds.Add(SET_COMMENT, True)
    retvaltype = Cmd.PutText("$$", COMMENT_TYPE, 0)
    retvaltype = Cmd.SetToggleString (1, OUTPUT_TYPE, 0)
     retvaltype = Cmd.PutText(Line1, COMMENT_FIELD, 1)
     retvaltype = Cmd.PutText(Line2, COMMENT_FIELD, 2)
     retvaltype = Cmd.PutText(Line3, COMMENT_FIELD, 3)
     retvaltype = Cmd.PutText(Line4, COMMENT_FIELD, 4)
     retvaltype = Cmd.PutText(Line5, COMMENT_FIELD, 5)
     retvaltype = Cmd.PutText(Line6, COMMENT_FIELD, 6)
     retvaltype = Cmd.PutText(Line7, COMMENT_FIELD, 7)
     retvaltype = Cmd.PutText(Line8, COMMENT_FIELD, 8)
     retvaltype = Cmd.PutText(Line9, COMMENT_FIELD, 9)
    End If
    
Reply
  • 
    
    '- - - - CUSTOM $$ DOCUMENT COMMENT, no options except "NOTE:" ------------------------------
    If lenstr13 > 0 And dlg1.CheckBoxE36 = 0 And dlg1.CheckBoxE46 = 0 Then
    Set Cmd = Cmds.Add(SET_COMMENT, True)
    retvaltype = Cmd.PutText("$$", COMMENT_TYPE, 0)
    retvaltype = Cmd.SetToggleString (1, OUTPUT_TYPE, 0)
    
     If dlg1.Checkbox7071 = 1 Then
     retvaltype = Cmd.PutText("NOTE: " + customstr13, COMMENT_FIELD, 1)
     End If
    
     If dlg1.Checkbox7071 = 0 And dlg1.CheckBoxE36 = 0 And dlg1.CheckBoxE46 = 0 Then
     retvaltype = Cmd.PutText(customstr13, COMMENT_FIELD, 1)
     End If
    
     If lenstr14 > 0 Then
     retvaltype = Cmd.PutText(customstr14, COMMENT_FIELD, 2)
     End If
    
     If lenstr15 > 0 Then
     retvaltype = Cmd.PutText(customstr15, COMMENT_FIELD, 3)
     End If
    
     If lenstr16 > 0 Then
     retvaltype = Cmd.PutText(customstr16, COMMENT_FIELD, 4)
     End If
    
     If lenstr17 > 0 Then
     retvaltype = Cmd.PutText(customstr17, COMMENT_FIELD, 5)
     End If
    
     If lenstr18 > 0 Then
     retvaltype = Cmd.PutText(customstr18, COMMENT_FIELD, 6)
     End If
    
     If lenstr19 > 0 Then
     retvaltype = Cmd.PutText(customstr19, COMMENT_FIELD, 7)
     End If
    
     If lenstr20 > 0 Then
     retvaltype = Cmd.PutText(customstr20, COMMENT_FIELD, 8)
     End If
    
     If lenstr21 > 0 Then
     retvaltype = Cmd.PutText(customstr21, COMMENT_FIELD, 9)
     End If
    
         If dlg1.Checkbox7072 = 1 Then
          Open "C:\TEMP\NEWCANNED.txt" For Output As #1
          print #1, customstr13
    
           If lenstr14 > 0 Then
           print #1, customstr14
           End If
    
           If lenstr15 > 0 Then
           print #1, customstr15
           End If
    
           If lenstr16 > 0 Then
           print #1, customstr16
           End If
    
           If lenstr17 > 0 Then
           print #1, customstr17
           End If
    
           If lenstr18 > 0 Then
           print #1, customstr18
           End If
    
           If lenstr19 > 0 Then
           print #1, customstr19
           End If
    
           If lenstr20 > 0 Then
           print #1, customstr20
           End If
    
           If lenstr21 > 0 Then
           print #1, customstr21
           End If
    
          Close #1
        End If
    
    Cmd.ReDraw
    End If
    
    
    '''''''''''' NEW CANNED COMMENT !$%%$^&#*^@%^!$%~%%^@^&^@$&*()_$*~!%!^% '''''''''''
          If dlg1.Checkbox7073 = 1 Then
    Dim Line1 As String
    Dim Line2 As String
    Dim Line3 As String
    Dim Line4 As String
    Dim Line5 As String
    Dim Line6 As String
    Dim Line7 As String
    Dim Line8 As String
    Dim Line9 As String
    
          Open "C:\TEMP\NEWCANNED.txt" For Input As #1
          Line Input #1, Line1
          Line Input #1, Line2
          Line Input #1, Line3
          Line Input #1, Line4
          Line Input #1, Line5
          Line Input #1, Line6
          Line Input #1, Line7
          Line Input #1, Line8
          Line Input #1, Line9
          Close #1
    
    Set Cmd = Cmds.Add(SET_COMMENT, True)
    retvaltype = Cmd.PutText("$$", COMMENT_TYPE, 0)
    retvaltype = Cmd.SetToggleString (1, OUTPUT_TYPE, 0)
     retvaltype = Cmd.PutText(Line1, COMMENT_FIELD, 1)
     retvaltype = Cmd.PutText(Line2, COMMENT_FIELD, 2)
     retvaltype = Cmd.PutText(Line3, COMMENT_FIELD, 3)
     retvaltype = Cmd.PutText(Line4, COMMENT_FIELD, 4)
     retvaltype = Cmd.PutText(Line5, COMMENT_FIELD, 5)
     retvaltype = Cmd.PutText(Line6, COMMENT_FIELD, 6)
     retvaltype = Cmd.PutText(Line7, COMMENT_FIELD, 7)
     retvaltype = Cmd.PutText(Line8, COMMENT_FIELD, 8)
     retvaltype = Cmd.PutText(Line9, COMMENT_FIELD, 9)
    End If
    
Children
No Data