TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: SOFITO_SOFT on June 16, 2011, 09:29:08 AM
-
This is a program for storing code and data in one file and enable others programs to modify the data ....
; >>>>>>>>>> helper program to read the main program, very useful during debugging >>>>>>
(defun c:ll (/)
(vl-load-com)
(setq acadDocument (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq mSpace (vla-get-ModelSpace acadDocument))
(or doc
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
)
(setq space mspace )
(setvar "REMEMBERFOLDERS" 1)
(setq arma_3d_path "h:\\AA_SOFITO\\") <<<<<< atention !!!!!
(load (strcat arma_3d_path "LEER-LSP.LSP"))
( C:LEER-LSP )
)
; <<<<<<<<<<<< end of helper program to read the main program
; >>>>>>>>>> main program >>>>>>
( DEFUN C:LEER-LSP ( / vari valor lec file lista-vari-valo arma_3d_path sent )
( setq arma_3d_path "h:\\AA_SOFITO\\") ; <<<<<< atention !!!!!
( setq lista-vari-valo '() )
( SETQ FILE ( OPEN (strcat arma_3d_path "LEER-LSP.LSP" ) "R" ) )
( WHILE ( SETQ LEC ( READ-LINE FILE ) )
( if ( = ( strcase lec ) "DATA" )
( progn
( SETQ LEC ( READ-LINE FILE ) )
( setq vari lec )
( SETQ LEC ( READ-LINE FILE ) )
( setq valor lec )
( set ( read vari ) valor ) ;<<<<< 1RT TRUCK !!!
( prompt ( strcat "\nTHE VARIABLE \"" VARI "\" IS NOW \"" VALOR "\" ." ) )
( getint "\nPulse para seguir..." )
( setq lista-vari-valo ( cons ( cons vari ( eval ( read vari ) ) ) lista-vari-valo ) )
)
)
( if ( = ( strcase lec ) "DATA-EVAL" )
( progn
( SETQ sent ( READ-LINE FILE ) )
( EVAL ( read sent ) ) ;<<<<< 2ND TRUCK !!!
( prompt ( strcat "\nSENTENCE ALSO HAS BEEN EVALUATED \"" SENT "\"" ) )
( getint "\nINTRO TO CONTINUE..." )
)
)
)
( CLOSE FILE )
; Verificating
( prompt "\nLIST VARIABLES AND VALUES IN LIST OF DOTED PAIR ..." )
( foreach n lista-vari-valo
( print n )
)
( princ )
)
;|
data
Paco
Suarez
data-eval
( setq tolo ( / 1 pi ) )
data-eval
( setq pipo ( strcat "Manuel" " " "Santana" ) )
data-eval
( setq pipa ( rem 1.2345 0.54 ) )
data-eval
( setq pipa2 ( * pipa 1000. ) )
|;
; <<<< end main program + data
Verificating variables and values....
Command:
Command: !paco
"Suarez"
Command: !tolo
0.31831
Command: !pipa
0.1545
Command: !pipa2
154.5
Greetings from Madrid...
-
I put ini type data in lisp files (book ended with ;| |;) then read it via doslib's dos_getini function (could roll my own but why bother when Dale has done such a good job); works very well for my needs.
-
Hello:
I also use "DOS_getini" using ".LSPs" as ". INIS" ... It was just someone who needed to put more data in LSP without complications ....
Congratulations to you brother Dale.... Magnificent library DOSLib ... .
Regards
-
For those interested ... make sure you create a section that serves only to "cap" the last "real" section, lest last section searches produce bogus key/data pairs.
In this example the [end] section caps [section3]. Use of the word "end' is arbitrary to dos_getini, just what I use.
;|
[section1]
key1=value1
key2=value2
key3=value3
[section2]
key1=value1
key2=value2
key3=value3
[section3]
key1=value1
key2=value2
key3=value3
[end]
|;
Hope that makes sense to you.
-
Warning; No where near on topic:
What a great idea. ...After a good hour of solid coding (std C++), ive got the first level of the above ini example parsed. Now i just need to figure out the sections and how they can fit in my model. humm...
BTW, thank you for the distraction; i needed it.
-
why not store data as a list and then just read it?
;|
'(data (section1 (key1 . value1) (key2 . value2) (key3 . value3)) (section2 (key1 . value1) (key2 . value2) (key3 . value3)))
|;
-
why not store data as a list and then just read it?
;|
'(data (section1 (key1 . value1) (key2 . value2) (key3 . value3)) (section2 (key1 . value1) (key2 . value2) (key3 . value3)))
|;
The idea is that an excel spreadsheet edit ( re-writre ) the LSP with news DATAS and variables / values.
The easiest method? . I do not know.
Greetings.
-
why not store data as a list and then just read it?
;|
'(data (section1 (key1 . value1) (key2 . value2) (key3 . value3)) (section2 (key1 . value1) (key2 . value2) (key3 . value3)))
|;
Is there a limit to the length of a line in a text file? (Just trying to think of why your idea wouldn't be viable)
-
Can't speak for others in the thread but I needed to embed meta data into lisp files tobe read by other lisp files, that is this.lsp would be read by that.lsp. The ini method was a no brainer and easy to implement. There are numerous ways it could be emulated, including vanilla lisp solutions, but I opted for the afore mentioned technique because of its simplicity, the "readability" of the data, and a format easy for others to understand and use, i.e. others add the meta data to the lisp files. :)