Macro to except a String Variable

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

Macro to except a String Variable

Postby Vmax549 » Fri Feb 02, 2018 1:43 pm

Could we have a macro to except a string var ??

M1019 {"string"}

or perhaps change one of teh Number vars to except a string?

M1019 { Q"string" }

Thanks (;-) TP
Vmax549
 
Posts: 912
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

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 2017 Screenset - http://www.thecncwoodworker.com/2017.html
ger21
 
Posts: 954
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: 416
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby Vmax549 » Fri Feb 02, 2018 6:45 pm

Just looking for an easy way for CAM to pass a string to UCCNC via Gcode

M999 {"String"} or M999 {A1.111 B2.222 Q"string"} would work about like the rest of the world does it.

HIYA Ger English was NOT my best sugject :o

(;-) TP
Vmax549
 
Posts: 912
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

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: 416
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby Vmax549 » Sat Feb 03, 2018 3:24 am

Hi Dezsoe, Yes I see what you did and it is a great example of parsing Gcode lines .

string xvar = Convert.ToString(Allvars.Qvar);

Is about as complicated as it needs to be or else teh average operator says forget it and walks away from creating usefull macros. And even that is overly complicated.

string xvar = Allvars.Qvar is how it needs to read.

IF one maintains a structure that is similar to Fanuc MacroB that is about the limit that 50% will tolerate. The other half will not even do MacroB saying it is too complicated.

To them it is like trying to read a hot romance novel written in Latin.

(;-) TP
Vmax549
 
Posts: 912
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

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: 416
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby Vmax549 » Sat Feb 03, 2018 2:24 pm

HI Dezsoe, LinuxCNC has been handling strings for a long time now as are other controllers. There really is no such thing as pure Gcode as there are many variants of it. Also there are other Machine code languages as well that don't even resemble Gcode.

So if you were developing a new controller would you not want the best of all the variants of Gcode?

Things that would make your controller more usefull for the operators that may need to make a living with it.

Note: (;-) I have already put your code snippet to work 8-) . I somewhat mimiced Tormachs PartView feature

M1019(gadget.png)

(;-) TP
Vmax549
 
Posts: 912
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

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: 416
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Macro to except a String Variable

Postby Vmax549 » Sat Feb 03, 2018 7:48 pm

HI Dezsoe. In LinuxCNC look up using named parameters.

(;-) TP
Vmax549
 
Posts: 912
Joined: Sun Nov 22, 2015 3:25 am
Location: USA

Next

Return to Feature Request

Who is online

Users browsing this forum: No registered users and 1 guest