This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: how to read a file in a string
- From: Damien MATTEI <damien dot mattei at unice dot fr>
- To: kawa at sourceware dot org
- Date: Tue, 15 Dec 2015 02:12:26 +0100
- Subject: Re: how to read a file in a string
- Authentication-results: sourceware.org; auth=none
- References: <566AA076 dot 7080008 at unice dot fr> <566AA29E dot 7030905 at itdesign dot de>
thanks
i finally wrote one code version doing it:
(define (read-counter-value fn)
(define cf &<{&[fn]})
(define toStringCF (gnu.lists.Blob:toString (->string cf)))
(display "------------------------------------")
(newline)
(display "counter value string:")
(display toStringCF)
(display "|")
(newline)
;;(define toIntegerCF (->int cf))
(if (string? toStringCF)
(display "toStringCF is a string !")
(display "toStringCF is NOT a string !"))
(newline)
(define toFStringCF (gnu.lists.FString toStringCF))
(display "------------------------------------")
(newline)
(display "last char string:")
(define lastCS (string-ref toFStringCF (- (string-length
toFStringCF) 1)))
(display (char->integer lastCS))
(display "|")
(newline)
;; (string-set! toFStringCF (- (string-length toFStringCF) 1)
#\space) ;; replace the trailing CR by a space
;; (display "counter value Fstring:")
;; (display toFStringCF)
;; (display "|")
;; (newline)
(define strCount (regex-split (string lastCS) toFStringCF))
(display "counter value strCount:")
(display strCount)
(display "|")
(newline)
(define rv (string->number (car strCount)))
(display "------------------------------------")
(newline)
(display "counter value:")
(newline)
(display rv)
(newline)
rv)
Damien
Le 11/12/2015 11:17, Dirk Huesken a Ãcrit :
Theres a section in the docs:
http://www.gnu.org/software/kawa/Reading-and-writing-whole-files.html
Regards,
Dirk