Functions to list directory and save array to file
-
Two items....
It would be handy if we had a function that emulated M20, but put the list into an array.
I recently did macro to allow the list of filaments to be displayed on a panelDue so the user can change filaments.
But there's no way to dynamically create the array based on the contents of the filaments directory.Also 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 useecho >"0:/sys/myArray.csv" {var.myArray}
, the created file include the curly brackets which cause fileread{} to choke.
Perhaps fileread() can strip the curly brackets if present?
This would save having a new function to write the array to file.var myArray = {"ABS","ASA","EDGE","eFlex","eLastic","FLEX","HIPS","NGEN","NYLON","PA-CF","PC","PCABS","PDVF","PEEK",} 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]