This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to read a file in a string


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]