Revise example.

This commit is contained in:
Brad Nelson
2024-11-14 21:05:55 -08:00
parent 8c010e1b24
commit 4ed9475c81
2 changed files with 12 additions and 5 deletions

View File

@ -36,6 +36,8 @@ r| What's the "time"?| askit >json a. cr cr
r| What's the "time"?| askit _s" contents" dict@ 0 a@ _s" parts" dict@ 0 a@ _s" text" dict@ >json a. cr
0 [IF]
_s" sample.txt" slurp json> _s" candidates" dict@ 0 a@ _s" content" dict@ _s" parts" dict@ 0 a@ _s" text" dict@ a.
HTTPClient
NetworkClientSecure.new constant nclient

View File

@ -12,11 +12,16 @@
\ See the License for the specific language governing permissions and
\ limitations under the License.
: slurp-file ( a n -- a n )
r/o open-file throw >r
needs arrays.fs
also arrays
: slurp ( a: filename -- a: content )
top range r/o open-file throw >r adrop
r@ file-size throw ( sz )
dup 1+ allocate throw swap ( data sz )
2dup r@ read-file throw drop
STRING array
top range r@ read-file throw drop
r> close-file throw
2dup + 0 swap c!
;
previous