Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

String Select

Recommended Posts

Hi to all, I need to select parts of a string.

That value is from a parameter table:

20200   sm_offset  --> 0. 0.238 0 0.125 0.113 1 1

The result is a string and I need separate the different numbers to others variables, is the same string or numeric.

I have tried the string select functions but no results for me.

Edited by eltklas
add text
Link to comment
Share on other sites

The 'rpar' function, grabs an 'Array' of 'space delimited' numeric variables from the line, starting from the 1st variable, and stopping where you tell it to stop (with the optional 2nd parameter)

So, you are telling the function, "get the first two variable values", starting from the 'first variable' in the list, which happens to be '0.'.

Because you used the value '2', you are telling the function to grab only the first two variables, from an "array" of variables.

If all you want is a single value, use 'rparsngl'. Plus, you need to use the 'sparameter$' String, as the "input" string, and use 'sm_offset' as the String to capture the result:

     if prmcode$ = 20200, sm_offset = rparsngl(sparameter$, 2)   #<- This will only capture the 2nd parameter, from the string.


All of the '20,xxx' series Tool Parameters, would be constantly written to the same string variable name, during processing 'sparameter$'.


You need to add this line of code to 'pparameter$' Post Block, for capture during normal processing.

If you also want that data "During the Tool Table (prwtt$) processing", you also need to add that line of code to 'pwrttparams$'.

Here is what it should look like (you may have other 'parameter read logic' in the Post Block, so just append your code "to the end of the block".

pwrttparam$     #Pre-read parameter data
      #"pwrttparam", ~prmcode$, ~sparameter$, e$
      if prmcode$ = 15346, comp_type = rpar(sparameter$, 1) #Cutter compensation type - 0=computer, 1=control, 2=wear, 3=reverse wear, 4=off
      if prmcode$ = 10010, xy_stock = rpar(sparameter$, 1)  #Capture stock to leave (XY)
      if prmcode$ = 10068, z_stock = rpar(sparameter$, 1)   #Capture stock to leave (Z)
      if prmcode$ = 20200, sm_offset = rparsngl(sparameter$, 2) #Capture the 2nd parameter from this string (for Tool Table)

pparameter$     #Read operation parameters
      #rd_params is used to call pparameter postblock and read the parameters of the operation specified in rd_param_op_no
      #"pparameter", ~prmcode$, ~sparameter$, e$
      if prmcode$ = 12025, rotary_axis2 = rpar(sparameter$, 1) #Capture the axis of rotation in Multiaxis Drill and Curve 5 Axis
      # Check To See if tool is metric
      if prmcode$ = 20007, toolismetric = rparsngl(sparameter$, 11)
      if prmcode$ = 20200, sm_offset = rparsngl(sparameter$, 2) #Capture the 2nd parameter from this string (during output)
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

  • Create New...