On 7.13.5 do not work, it display it only on terminal, not create any variable or is of any use...From ROS version 7.13 there is /file/read command (currently undocumented) which you can use to read file chunked with arguments chunk-size and offset. First, fetch command will need to download whole file on to FS and not be used to return response data as value to variable.
This can be useful for parsing text by some delimiter, to read file chunked and hold characters buffer variable until delimiter is reached (assuming that text between delimiters will not reach variable size limit). In your case it can be done since new line is delimiter and lines are not long, but this read feature it still not enough for parsing large meta data files like json (depends on structure, some can be parsed like large arrays of smaller items).
But if on future is fixed, like adding as-value or similar...
actually not working example code
:global readfile do={ :local url $1 :local thefile "" :local filesize [/file get $1 size] :local maxsize 32768 ; # is the actual maximum supported readable size of a block from a file :local start 0 :local end ($maxsize - 1) :local partnumber ($filesize / ($maxsize / 1024)) :local reminder ($filesize % ($maxsize / 1024)) :if ($reminder > 0) do={ :set partnumber ($partnumber + 1) } :for x from=1 to=$partnumber step=1 do={ :set thefile ($thefile . [/file read file=$1 chunk-size=$maxsize offset=$start as-value]) :set start ($start + $maxsize) :set end ($end + $maxsize) } :return $thefile}:local test [$readfile test.txt]
Statistics: Posted by rextended — Mon Mar 04, 2024 1:43 pm