Revise example.
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user