Michael, I've had a quick look at the functions
closebin, openbin, readbin, writebin As Owen indicated, the signatures seem to be ;
(odcl_openbin "<filename>" {"r"|"w"}) => opens a file for read or write and returns a file handle
(odcl_closebin <file-handle>) => closes a previously opened file
(odcl_writebin <file-handle> <data1> <data2> ...) => persists arbitrary lisp
data to the file (lists may not be nested more than 2 levels deep)
(odcl_readbin <file-handle>) => reads and returns a list of all data items in the file
The results of testing indicates that some work needs to be done to make the functions bombproof .. but they do work ..
;;///--------------------
;; Test 01
;;
(SETQ fnHandle (ODCL_OPENBIN "c:\\testBinFile-1" "w"))
;;->159287144
(SETQ tmp (ODCL_WRITEBIN fnHandle "Test Data" 1234 56.7 (LIST 8 9)))
;;-> T
;;File must be closed.
(SETQ tmp (ODCL_CLOSEBIN fnHandle))
;;-> nothing ??
;;NOTE : if file is saved twice an Unhandled Exception Reading Violation is generated.
(SETQ fnHandle (ODCL_OPENBIN "c:\\testBinFile-1" "r"))
;;-> 159287864
(SETQ tmp (ODCL_READBIN fnHandle))
;;-> "Test Data"
(SETQ tmp (ODCL_READBIN fnHandle))
;;-> 1234
(SETQ tmp (ODCL_READBIN fnHandle))
;;-> 56.7
(SETQ tmp (ODCL_READBIN fnHandle))
;;-> (8.0 9.0)
(SETQ tmp (ODCL_READBIN fnHandle))
;;-> nothing ??
;;NOTE : if file is read further an Unhandled Exception is generated.
;;File must be closed.
(SETQ tmp (ODCL_CLOSEBIN fnHandle))
;;-> nothing returned ??
;;///--------------------
;; Test 02
(SETQ fnHandle (ODCL_OPENBIN "c:\\testBinFile-1" "r"))
;;-> 159288584
(SETQ res 0
result '()
)
(WHILE res
(SETQ res (ODCL_readBIN fnHandle)
result (CONS res result)
)
(VL-PRIN1-TO-STRING result)
)
;;-> Unhandled exception, then "(nil (8.0 9.0) 56.7 1234 \"Test Data\")"
(SETQ tmp (ODCL_CLOSEBIN fnHandle))
;;///--------------------
;; Test 03
;;
(SETQ fnHandle (ODCL_OPENBIN "c:\\testBinFile-03" "w"))
;;->159287144
(SETQ
ent (car (entsel))
tmp (ODCL_WRITEBIN fnHandle (list "Test Data" 1234 56.7 (LIST 8 9) ent )))
;;-> T
;;File must be closed.
(SETQ tmp (ODCL_CLOSEBIN fnHandle))
(SETQ fnHandle (ODCL_OPENBIN "c:\\testBinFile-03" "r"))
(SETQ tmpdata (ODCL_READBIN fnHandle))
;;-> ("Test Data" 1234 56.7 (8.0 9.0) <Entity name: 7efbb2f0>)
(SETQ tmp (ODCL_CLOSEBIN fnHandle))
.
The data appears to work best at the moment wrapped as a list. Sequential data blobs cause an issue.
As subsequent reads step through the saved items having some form of counter would be handy, or having an identifier for the end of the list ... I'm not sure that 'nil' returned at the end on the data would be suitable because one of the data items may have a nil value and confuse the issue.
These functions definately have potential and I can see their inclusion enhancing the product.
The (odcl_readbin .. does not behave nicely ..