Duet3D / RepRapFirmware

OO C++ RepRap Firmware
GNU General Public License v3.0
945 stars 535 forks source link

[FeatureRequest]: Function to save array to a file. #951

Open owendare opened 9 months ago

owendare commented 9 months ago

Is your feature request related to a problem? Please describe.

it would be good if you could write an array to file in a format that was compatible with fileread() At present to achieve this requires something like the macro below because if you use echo >"0:/sys/myArray.csv" {var.myArray} , the created file include the curly brackets which cause fileread{} to choke.


var myString = ""
while iterations < #var.myArray
    set var.myString = var.myString ^ """" ^ var.myArray[iterations] ^ """" ^ ","
echo >"0:/macros/conditional_g_code_macros/myArray.csv" var.myString
var readBackArray = fileread("0:/macros/conditional_g_code_macros/myArray.csv",0,{#var.myArray},',')
echo var.readBackArray
echo var.readBackArray[0] ^ " : " ^ var.readBackArray[#var.readBackArray-1]```

### Describe the solution you propose.

Apparent choices are..
1.  Modify echo> command to strip curly brackets from arrays before saving to file.
2.  Create dedicated function to save arrays to file.
Option 1 would seem more logical.

### Describe alternatives you've considered

Perhaps fileread() can strip the curly brackets if present?
This would save having a new function to write the array to file.

### Provide any additional context or information.

Ex. Photos, mockups, etc.
T3P3 commented 9 months ago

Reasonably low priority as there is a workaround