Hello Guest it is April 19, 2024, 02:25:29 PM

Author Topic: Mach4: API "Gcode File" syntax error  (Read 2458 times)

0 Members and 1 Guest are viewing this topic.

Mach4: API "Gcode File" syntax error
« on: September 10, 2018, 05:11:58 AM »
Hi everyone,

I'm writing script in Mach4 to read a Gcode line for calculation, but function mcCntlGetGcodeLine, mcCntlGetGcodeLineCount appears "syntax error" when I compile, I tried to change the syntax but error still apear, Please help me fix this error, thank you.
My code:
       inst = mc.mcGetInstance()
       local int LineNumber = 5 --line number need to read
       local char Gcodeline[128]
       
Syntax No1:  mc.mcCntlGetGcodeLine(inst, LineNumber, Gcodeline, 128) --Get line number 5 from the Gocde file loaded into controller

or Syntax No2:   Gcodeline = mc.mcCntlGetGcodeLine(inst, LineNumber)
Re: Mach4: API "Gcode File" syntax error
« Reply #1 on: September 10, 2018, 07:05:50 AM »
Hi,
just a guess but Lua is not type declared.....try removing the 'int' and 'char' from you variable definitions.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4: API "Gcode File" syntax error
« Reply #2 on: September 10, 2018, 07:59:21 AM »
Thank you Mr. Craig, there is no error now, the correct code is:
      
       inst = mc.mcGetInstance()
       local LineNumber = 5
       local Gcodeline      

       mc.mcCntlGetGcodeLine(inst, LineNumber, Gcodeline, 128) --Get line number 5 of the Gocde file loaded.

or:   Gcodeline = mc.mcCntlGetGcodeLine(inst, LineNumber)--Get line number 5 of the Gocde file loaded.