Macro to except a String Variable

Here is where you can request new features or special features.

Re: Macro to except a String Variable

Postby ger21 » Fri Feb 02, 2018 2:09 pm

I think it already Excepts the string. But you probably want it to Accept it. :D
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2714
Joined: Sat Sep 03, 2016 2:17 am

Re: Macro to except a String Variable

Postby dezsoe » Fri Feb 02, 2018 4:50 pm

I've just uploaded a macro in the TOOLBOX, you can get ideas how to pass a string to a macro.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby dezsoe » Fri Feb 02, 2018 7:15 pm

I've just shown you the way. Pass it through a remark:

Code: Select all
M1000 (this all text will go to variable msg)

And use this macro M1000:

Code: Select all
// ================================================================================================

string myLine = exec.Getcurrgcodelinetext();
string msg = "";
int posF = 0;
int posL = 0;

if (myLine != null)
{
  posF = myLine.IndexOf("(");
  if (posF != -1)
  {
    posL = myLine.LastIndexOf(")");
    if (posL > posF)
      msg = myLine.Substring(posF + 1, posL - posF - 1);
  }
}

if (msg != "")
{
  // --- Now msg contains the full text of the remark between ( and ) ---
  // WRITE YOUR CODE HERE
}

// ================================================================================================
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby dezsoe » Sat Feb 03, 2018 11:57 am

Hi Terry,
There's no way in g-code to handle strings. The whole standard and structure of the g-code is against that. It doesn't depend on tha way the parameters are passed, so Fanuc (or LinuxCNC) #1..#26 (..#30, ..#33) will also not solve the problem. It's not a hard thing to develop the string management, but it is not the standard, so it is not g-code. You can modify your car to be able to wash your clothes, technically it's not impossible, but you don't want it, because a car is not for washing, but travelling.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby dezsoe » Sat Feb 03, 2018 4:03 pm

Vmax549 wrote:HI Dezsoe, LinuxCNC has been handling strings for a long time now as are other controllers.

Before I sent my last post I tried to find some info on other controllers. In the LinuxCNC handbook I found:
The only value type supported by parameters is floating-point; there are no string, boolean or integer types in G-code like in other programming languages.

I don't know LinuxCNC, I used it only for some weeks when I started to build my first machine some years ago. I can't decide who's right. :) Could you please show some sample code? For now, I'm really interested in this. :)
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby dezsoe » Sat Feb 03, 2018 9:10 pm

Well, they are very awful... :) But! They are not string types. They are floating point variables as the #nnn-s, just have some awful name instead of the #nnn form.
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby dezsoe » Sun Feb 04, 2018 10:10 am

The command is calling a NAME(string) then it refers to a number internally

<holediam> = 25.33

Also I believe they used teh same approach with M98

M98<BoltCircle> L1 Calls a remote sub named BoltCircle

A lot of controls use strings for various features.

OK, these are only references to numeric variables (or constants), not string type variables. The string type is not g-code.

I think I give it up now, because I see that I cannot convince you of this. :)
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary


Return to Feature Request

Who is online

Users browsing this forum: No registered users and 5 guests