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
  • Like 1
Link to comment
Share on other sites
  • 1 month later...
On 3/17/2023 at 1:15 PM, eltklas said:

Thank you, Works well.

But I thought that in the new versions from 2017 we would not have to use that old way since they added opinfo and the parameter tables. 

Thankks for your quick response.

 

Kind of a late response, but I'll take a stab at this.

Your title was "String Select", and the example you gave was using 'rpar'. That is the old-school function for getting the data.

There is a whole bunch of new functions in the MP Language, but I have yet to see practical examples, and posts written "from the ground up with only the new functionality", as examples from CNC Software. To be fair, I also haven't looked too hard recently to see if any exist either.

I use all the old-school functions because 99% of the people asking Post Questions, on this forum, are using a Post that uses the old 'Parameter Table/Pre-Read' functions (pparameter$ and pwrttparams$). 

 

  • Thanks 1
  • Like 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.

Guest
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.

 Share

  • 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...