test_code()

Tests a G-code program from a string for validity by loading and validating its G-code lines.

Syntax

test_code(gcode_string)

Parameters

Parameter Type Description
gcode_string String A string containing G-Code commands to validate.

Return Value

Examples

Test G-Code from a string for validity

test_code("G21\nG0 X10 Y10\nM3\nG1 X50 Y50 F1000\nM5");  // returns 0 if valid, or an error line number

Test another G-Code program from a string

test_code("G90\nG0 Z5\nG1 X100 Y100 Z0 F500");  // returns 0 if valid, or an error line number

See also

open_file
open_code
start_file
start_code
test_file
test_code