Home   Archive   Permalink



need help with load word

trying to load a file into a variable, always get this error:
    
files: load %testytest
** Syntax Error: Invalid integer -- 12M
** Near: (line 1) total 12M
    
testytest is just the output of the ls command of a directory. it starts like this:
    
total 12M
1.8M -rw-rw-r-- 1 1.8M Feb 7 14:41 Screenshot_20220207_144100.png
2.4M -rw-rw-r-- 1 2.4M Feb 8 01:35 Screenshot_20220208_013501.png
...
    
I want this to be a block. I somehow did it before, but changed some things and now I can't do it again.


posted by:   cricket     17-Mar-2022/12:54:16-7:00



when I did it before, if I ran the command probe files/6 it would return Feb

posted by:   cricket     17-Mar-2022/13:13:24-7:00



the directory is just a bunch of pictures. the full ls command is "ls -lshog ./testing > testytest" I want that output file which is just a list of what's in the directory to be the block 'files

posted by:   cricket     17-Mar-2022/15:48:26-7:00



"12M" is not a valid REBOL value, as the error message says. You can't parse this format just with LOAD.
    
You could write a parser for it with PARSE, or you could do some preprocessing to make it valid REBOL, so you could use LOAD after that.

posted by:   Kaj     18-Mar-2022/10:38:16-7:00



But why don't you just use "read %."?

posted by:   Kaj     18-Mar-2022/10:41:19-7:00



>> files: read %testytest                                                
== {total 12M
1.8M -rw-rw-r-- 1 1.8M Feb 7 14:41 Screenshot_20220207_144100.png
2.4M -rw-rw-r-- 1 2.4M Feb 8 01:35 Screenshot_20220...
>> b: copy [] foreach a parse/all files "^/" [repend/only b parse/all a " "]
== [["total" "12M"] ["1.8M" "-rw-rw-r--" "1" "1.8M" "Feb" "7" "14:41" "Screenshot_20220207_144100.png"] ["2.4M" "-rw-rw-r--" "1" "2...
>> b/2/8
== "Screenshot_20220207_144100.png"

posted by:   Sergey_Vl     20-Mar-2022/5:17:10-7:00



...and you can try do not use temp-file "testy test"
>>files: copy "" call/output ""ls -lshog ./testing" files


posted by:   Sergey_Vl     20-Mar-2022/5:40:35-7:00



Name:


Message:


Type the reverse of this captcha text: "l o c o t o r P - t o o R"



Home