hexagon logo

TRACEFIELD Scripting Modification

http://www.pcdmisforum.com/showthread.php?27544-Tracefields-and-Scripts&highlight=tracefield+script

Long time lurker and PC-DMIS user, first time posting - and going to get deep here...
Did some searching, and the most similar topic to what I've been looking for is above.

However, what I need is to temporarily - or for one TRACEFIELD item - define the object as a numeric value (Integer preferably...) instead of a String value.

I'm wondering how to pull this off elegantly? I'm somewhat new to scripting but have dabbled scripting in Excel, Access, etc. in the past. Mostly editing and not inventing the wheel, so-to-speak.

I really need to figure out a way to do this or I'll go insane trying - and breaking -stuff. Slight smile

I was thinking of just copying the command and inserting a new assignment for the TRACE_VALUE field, but not sure if that will work. I'm looking for advice here since I don't want to do more harm than good.

Thanks for any help!

Set DmisCommand = DmisCommands.Add(TRACEFIELD, True)
    DmisCommand.Marked = True
  ' Set Name  = Job
    retval = DmisCommand.PutText ("Job", TRACE_NAME, 0)
  ' Set Value  = 0
    retval = DmisCommand.PutText ("0", TRACE_VALUE, 0)
  ' Set Value Limit  = 15
    retval = DmisCommand.PutText ("15", TRACE_VALUE_LIMIT, 0)
  Result = DmisCommand.SetExpression("C2.INPUT", TRACE_VALUE, 0)


I believe I found that TRACE_VALUE is Dim'd as String. I need it to be Integer for one value and String for all others.

Edited to add that it's ok if the value is Long or Double or Integer - as long as it's numeric....
Parents
  • Thank you for your reply.

    The need is that these TRACEFIELDS go into Datapage (STATS ON) for statistics and the type needs to be numeric, not text or string, for the final receiving statistics database (QC Calc).

    I go back and forth on whether this can even be done... Datapage/STATS creates the .TMP file but it's a document with space or comma delimited data... is that even recognizable as a "type" at that point? I'm guessing if it is a value like 1.0000 (long) vs. 1 (integer), it would be at any rate...

    On the other hand, with scripting, just about anything can be manipulated, right? Just the how is what I'm looking to do.

    Other output software (like Calypso and MeasureMind, etc) we can specify the TYPE for any output field. This carries through into the database. In the TRACEFIELD command, it is hard-coded as string. This is what I need a work around for. The database needs to recognize the traceable data as a numeric value so as to not be recognized if searched/sorted for in a text field (if that makes sense).

    The use of the field will be a sequence number for part traceability. It could also be a numeric lot number or anything else that is numeric.

    Is there another route to do a work-around and add a numeric field into the .TMP file without the TRACEFIELD command? I'm open to that route, if it exists.

    Otherwise, I'll be trying to redefine the type of the TRACE_VALUE field in the TRACEFIELD command, or a temporary fascimile.

    I found the examples in the BASIC help like this one:

    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
    
    Sub Main()
    'Get operator Name And assign it To variable: N$.
    N$ = InputBox$("Please enter your name:", "Operator", "", 200, 175)
     
    'The following section adds a comment cmd To the part program
    Dim App As Object
    
    'Get the pointer To the PC-DMIS application
    Set App = CreateObject("PCDLRN.Application")
    Dim Part As Object
    
    'Get the pointer To the current part program
    Set Part = App.ActivePartProgram
    Dim Cmds As Object
    
    'Get the pointer To the Set of commands In the part program
    Set Cmds = Part.Commands
    Dim Cmd As Object
    
    'Add a COMMENT command
    Set Cmd = Cmds.Add(SET_COMMENT, True)
    
    'Set the comment's Type To REPT
    retvaltype = Cmd.PutText("REPT", COMMENT_TYPE, 0)
     
    'Put the String held In variable N$ into the comment's text
    retvaltext = Cmd.PutText(N$, COMMENT_FIELD, 1)
     
    'Redraws the COMMENT command so that the applied changes are applied To the part program
    Cmd.ReDraw
    End Sub


    My variable is coming from a Form, not a message box, but it is operator dependent. I'm wondering if the route above would work as a pseudo TRACEFIELD command...? (Modified, of course.)
Reply
  • Thank you for your reply.

    The need is that these TRACEFIELDS go into Datapage (STATS ON) for statistics and the type needs to be numeric, not text or string, for the final receiving statistics database (QC Calc).

    I go back and forth on whether this can even be done... Datapage/STATS creates the .TMP file but it's a document with space or comma delimited data... is that even recognizable as a "type" at that point? I'm guessing if it is a value like 1.0000 (long) vs. 1 (integer), it would be at any rate...

    On the other hand, with scripting, just about anything can be manipulated, right? Just the how is what I'm looking to do.

    Other output software (like Calypso and MeasureMind, etc) we can specify the TYPE for any output field. This carries through into the database. In the TRACEFIELD command, it is hard-coded as string. This is what I need a work around for. The database needs to recognize the traceable data as a numeric value so as to not be recognized if searched/sorted for in a text field (if that makes sense).

    The use of the field will be a sequence number for part traceability. It could also be a numeric lot number or anything else that is numeric.

    Is there another route to do a work-around and add a numeric field into the .TMP file without the TRACEFIELD command? I'm open to that route, if it exists.

    Otherwise, I'll be trying to redefine the type of the TRACE_VALUE field in the TRACEFIELD command, or a temporary fascimile.

    I found the examples in the BASIC help like this one:

    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
    
    Sub Main()
    'Get operator Name And assign it To variable: N$.
    N$ = InputBox$("Please enter your name:", "Operator", "", 200, 175)
     
    'The following section adds a comment cmd To the part program
    Dim App As Object
    
    'Get the pointer To the PC-DMIS application
    Set App = CreateObject("PCDLRN.Application")
    Dim Part As Object
    
    'Get the pointer To the current part program
    Set Part = App.ActivePartProgram
    Dim Cmds As Object
    
    'Get the pointer To the Set of commands In the part program
    Set Cmds = Part.Commands
    Dim Cmd As Object
    
    'Add a COMMENT command
    Set Cmd = Cmds.Add(SET_COMMENT, True)
    
    'Set the comment's Type To REPT
    retvaltype = Cmd.PutText("REPT", COMMENT_TYPE, 0)
     
    'Put the String held In variable N$ into the comment's text
    retvaltext = Cmd.PutText(N$, COMMENT_FIELD, 1)
     
    'Redraws the COMMENT command so that the applied changes are applied To the part program
    Cmd.ReDraw
    End Sub


    My variable is coming from a Form, not a message box, but it is operator dependent. I'm wondering if the route above would work as a pseudo TRACEFIELD command...? (Modified, of course.)
Children
No Data