Firmware: 3.5.0-beta.4
Duet web control: 3.5.0-beta.4
I am working on a script to write several global variables to a file, per a series of messages sent to a user, so the user can get the right set of variables for their printer after executing the script.
The first part of the code (line 1 through 15) work well, and in the resulting config_globals.g, the first parameters (version 1 or version 2) are set correctly
However the second set of parameters (printer model 1 or 2) are not set at all, it seems as if nestling the echo commands that deep is causing problems.
M30 "0:/sys/test/config_globals.g"
M28 "0:/sys/test/config_globals.g"
M29
M291 T0 S4 R"Welcome" P"Welcome to your Printer. Please select the version of printer you have" K{"V1","V2"}
if input = 0
M291 S3 R"Version V1" P"According to this, you have a V1 printer. Press OK to confirm, or cancel to re-start"
echo >"0:/sys/test/config_globals.g" "if !exists(global.config_version)"
echo >>"0:/sys/test/config_globals.g" " global version = 1"
global version = 1
if input = 1
M291 S3 R"Version V2" P"According to this, you have a V2 printer. Press OK to confirm, or cancel to re-start"
echo >"0:/sys/test/config_globals.g" "if !exists(global.config_version)"
echo >>"0:/sys/test/config_globals.g" " global version = 2"
global version = 2
if global.version = 1
M291 T0 S4 R"V2 to V3" P"Do you have a A model or a B model" K{"A model","B model"}
if input = 0
echo >>"0:/sys/test/config_globals.g" " global printer-model = 1"
global printer-model = 1
if input = 1
echo >>"0:/sys/test/config_globals.g" " global printer-model = 2"
global printer-model = 2
elif global.version = 2
M291 T0 S4 R"V2 to V3" P"Do you have a C model or a D model" K{"C model","D model"}
if input = 0
echo >>"0:/sys/test/config_globals.g" " global printer-model = 1"
global printer-model = 1
if input = 1
echo >>"0:/sys/test/config_globals.g" " global printer-model = 2"
global printer-model = 2
The output of this file, selecting first version 1 and then printer model 1 is this:
if !exists(global.config_version)
global version = 1
However the expected and desired code is:
if !exists(global.config_version)
global version = 1
global printer-model = 1
Executing the echo commands separately does work, so I am not sure why the commands are not working when used in this fashion.
As another test, I also created two files named version1.g and version2.g, that contained the sub-scripts. In that case, the echo commands correctly wrote the global parameters to the config_globals.g
if global.version = 1
M98 P"0:/sys/test/version1.g"
elif global.version = 2
M98 P"0:/sys/test/version2.g"
version1.g example:
M291 T0 S4 R"V2 to V3" P"Do you have a A model or a B model" K{"A model","B model"}
if input = 0
echo >>"0:/sys/test/config_globals.g" " global printer-model = 1"
;global printer-model = 1
if input = 1
echo big120x
echo >>"0:/sys/test/config_globals.g" " global printer-model = 2"
;global printer-model = 2