[SOLVED] Does not fit in word ! for dcl_ProjectImport, how to ?

Started by stephan_35, September 03, 2009, 01:27:04 AM

Previous topic - Next topic

stephan_35

Hello,

Here is my code to save an lisp file.
In this file i would like to set the variable for import the project.

Code (autolisp) Select

(setq $project:name (dcl_Project_Load (strcat $path "project.odcl") T))
 ; Make the lisp file ;Construction du fichier projet Lisp OpenDCL
 (setq #File (open (strcat (strcat $path "Constantes_odcl.lsp")) "w"))
 (if #file
   (progn
     (write-line (strcat "(setq $opendcl \"" (setq $opendcl (dcl_Project_Export $project:name)) "\")") #file)
     (close #file)
     ; Unload project ;Décharge le projet
     (dcl_Project_UnLoad $project:name)
     ; Open lisp file ; Réouvre le fichier
     (load (strcat (strcat $path "Constantes_odcl.lsp"))) ; Failed here !!!
     )
   )
 (dcl_project_import $opendcl)
 ; Show palette ;Affichage de la palette
 (dcl_Form_Show DynaBib_Pal1)


Yes, Failed to load lisp file, because string too much long!

Code (autolisp) Select
(setq $opendcl "too much long string here")


I would like to be able to make this file like this (see in example):

Code (autolisp) Select

(setq project
           '(
               "YWt6A20SAADAoypBBuKTKTUSKztmgFDDvn83WlYjKwzT3hP22gg0l0u45lXk1sPKQLS8Mz0RRSxX"
               Many lines here ! ...
               "jDCBFPYBxvLSDwxjswy5uQG0K+fe"
           )        
       )


My sting $opendcl have return code \r\n, but i don't really remember (or know) wich vlisp order will help me to explode this string.

Thanks for help !

Best regards.
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

stephan_35

ok, i do it another way :

The lenght of string was 71846 byte,
I saved it in a text file for check like this :
Code (autolisp) Select

(write-line (strcat ";" (VL-PRIN1-TO-STRING (dcl_Project_Export $project:name))) #file)


Check lisp:
Code (autolisp) Select

;"YWt6Az9YAwB482FhBuKSA3kiahmEgb0jkBwc9Om1W4mxmwk5bO3mHJHk/CNtBakmPr/s1lY7zx+R\r\nI88e...


Then i made a function to explode the string into a list of 76 byte per line.
Then added this into my check lisp:

Code (autolisp) Select

;"YWt6Az9YAwB482FhBuKSA3kiahmEgb0jkBwc9Om1W4mxmwk5bO3mHJHk/CNtBakmPr/s1lY7zx+R\r\nI88e...
(setq &opendcl (list
"YWt6Az9YAwB482FhBuKSA3kiahmEgb0jkBwc9Om1W4mxmwk5bO3mHJHk/CNtBakmPr/s1lY7zx+R"
....
))


After this, i read my check lisp and added all string of my list in an alone string .. (hope someone understand !)

Code (autolisp) Select

      (foreach $tmp &opendcl
(setq $opendcl (strcat $opendcl $tmp))
)


Right ?

Now, i rewrite again my result into my check lisp
Code (autolisp) Select

(write-line (strcat ";" (VL-PRIN1-TO-STRING $opendcl)) #file)


Now my check lisp file contain:
Code (autolisp) Select

;"YWt6Az9YAwB482FhBuKSA3kiahmEgb0jkBwc9Om1W4mxmwk5bO3mHJHk/CNtBakmPr/s1lY7zx+R\r\nI88e...
(setq &opendcl (list
"YWt6Az9YAwB482FhBuKSA3kiahmEgb0jkBwc9Om1W4mxmwk5bO3mHJHk/CNtBakmPr/s1lY7zx+R"
....
))
;"YWt6Az9YAwB482FhBuKSA3kiahmEgb0jkBwc9Om1W4mxmwk5bO3mHJHk/CNtBakmPr/s1lY7zx+R\r\nI88e...


Look like the same ???

Check again the length of my new string .

oh oh ! not the same lenght, (69674) but same string in my file !

What's wrong ?

Thanks for help .
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

stephan_35

ok contain some non printable ascii !
Will try another way .
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

stephan_35

Work this way :

Code (autolisp) Select

(setq &opendcl (vl-string->list (setq $opendcl(dcl_Project_Export $project:name))))
(write-line (strcat "(setq &opendcl \(quote" (VL-PRINc-TO-STRING &opendcl) "\)\)") #file)
(close #file)
(load (strcat (strcat $path "Constantes_odcl.lsp")))
(setq $opendcl (vl-list->string &opendcl))
(dcl_Project_UnLoad $project:name)
(dcl_project_import $opendcl)


Now, this tools make a lisp file, to set variable input for dcl_Project_import.

Just have to put a test if odcl file is present for making it.

Impossible to integer it in fas file :
Quote
does not fit in word: 71846
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

You have the right idea breaking it into a list of strings, but there's no need to add the (setq $opendcl) part.  Instead, make it a plain old list, then (setq $opendcl (load "<filename>")).

stephan_35

Quote from: owenwengerd on September 03, 2009, 07:43:22 AM
You have the right idea breaking it into a list of strings, but there's no need to add the (setq $opendcl) part.  Instead, make it a plain old list, then (setq $opendcl (load "<filename>")).

I don't really understand what you mean by old list  ...   :-[

I don't know how to solve the problem of non printable char with breaking into list, that's why i tried to breaking them into ascii code.

My final problem is that the filed is too long "does not fit in word".

Thanks, best regards.
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

Try saving the file from Studio with a .lsp extension, then open the resulting file in Notepad and Save As to the same name, but change the encoding to ANSI.  Does the ANSI encoded file work for you?

stephan_35

Quote from: owenwengerd on September 03, 2009, 11:20:46 AM
Try saving the file from Studio with a .lsp extension, then open the resulting file in Notepad and Save As to the same name, but change the encoding to ANSI.  Does the ANSI encoded file work for you?

I tried to save from studio [6.0.0.2], set lisp file, Saving the project, nothing append !

I never did it before .

Did i miss something with studio ?

Thanks.

OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

If nothing happened, then you missed something. What exactly did you do?

stephan_35

Quote from: owenwengerd on September 03, 2009, 12:03:22 PM
If nothing happened, then you missed something. What exactly did you do?

Ok,

First, open the project with studio 6.0.0.2

Then, Set AutoLisp File Name : "H:\...\...\Project_odcl.lsp"

Then , in menu Tools, select Write events to lisp file.

Then, Save the project .... I don't know what action i have to do ....

Then quit the project

Then verify my lisp file ... nothing inside ?

Thanks


Thanks

OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

owenwengerd

When you save the file, type a filename with a .lsp extension.

stephan_35

Quote from: owenwengerd on September 03, 2009, 12:28:37 PM
When you save the file, type a filename with a .lsp extension.

Ok , i'm so stupid ... !!!

Yes, i have to go to the file menu, then save as a lisp File !

Very sorry to have disturb you  :-[

Work fine now !

Will now go to bed ... and send you back tomorrow.

Thanks owen.

Best regards.
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

stephan_35

Hello owen,

Here are some words for some news.

I confirm you that it's necessary to change saved opendcl lisp file to ansi code, with 6.0.0.2 Studio editor.

But not with 5.1.2.1 Studio editor (Wich have a little bug, it added 2 strange ascii code before all data .

I give up trying to make myself lisp file with dcl_export (Maybe try again next week) , because i must insert my "(setq $opendcl" before data, due to compiling into fas file.

Thanks, best regards.
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql

stephan_35

Hello,

Here is my soluce, if it can help somebody.

Why ?
Because, i wanted to integer the dcl_ProjectImport inside a compiled fas file, so impossible to launch a load order inside.

How ?
Two case, first odcl file is present, so read-it normaly, then export it in a lisp file, wich would be integer in the next compiled fas file. with my exemple.
Second cas, odcl file is absent, so, your soft tools will use the precompiled definition of odcl.

Wich soluce ?
As you can see, i tried several method, the highter problem was to break the ascii code without lost special char for non printable ascii.
Every try to work directly with string were aborted !
First, transform all ascii into an list of ascii code.
Second, because it's impossible to integer a long list into a lisp file, i have to break this list into several inside list (hope understand)
thirs, save this list into a lisp file which is include in the list of file to be compiled in the fas file...

here is code, as is.

Function to create the included list of list.

Code (autolisp) Select

(defun @vl-string-to-list-in-len ( $string #len / &tmp &stmp &result )
  (setq &tmp (vl-string->list $string)) ; Transfert en liste
  (setq #cpt 1 &stmp nil)
  (foreach #tmp &tmp
    ; si on dépasse le nombre par sous liste
    (if ( > #cpt #len)
      (progn
(if &result
  (setq &result (append &result (list &stmp)))
  (setq &result (list &stmp))
  )
(setq #cpt 1 &stmp nil)
)
      )
    (if &stmp
  (setq &stmp (append &stmp (list #tmp)))
  (setq &stmp (list #tmp))
  )
(setq #cpt (1+ #cpt))
    )
  ; ajoute le solde
  (if &result
  (setq &result (append &result (list &stmp)))
  (setq &result (list &stmp))
  )
  )


Now, here is the first step, load odcl, then break it to list in list.
Code (autolisp) Select

(setq $project:name (dcl_Project_Load (strcat $path "Project.odcl") T))
; Exporte le projet
(setq &opendcl (@vl-string-to-list-in-len (dcl_Project_Export $project:name "By AD-Informatique") 76))
(setq #File (open (strcat (strcat $path "FileToIncludeInFas_odcl.lsp")) "w"))
(write-line (strcat "(setq &opendcl \(quote" (VL-PRINc-TO-STRING &opendcl) "\)\)") #file)
(close #file)


Now load just saved file to check it !

Code (autolisp) Select

; On Controle !
(load (strcat $path "FileToIncludeInFas_odcl.lsp"))
; On recréé la structure
(setq &opendcl:loaded nil)
(foreach &tmp &opendcl
  (if &opendcl:loaded
    (setq &opendcl:loaded (append &opendcl:loaded &tmp))
    (setq &opendcl:loaded &tmp)
    )
  )
;(length &opendcl:loaded)
(setq $opendcl (vl-list->string &opendcl:loaded))
(setq $project:name (dcl_project_import $opendcl "By AD-Informatique"))



PS: You have to insert all control as needed.
OpenDCL 6.0.0.6 / Editor 5.1.2.3  / Vista 32 Bits
Development of  specific tools for trades in AutoLisp - php - sql