#1
|
|||
|
|||
List box with specific directory ?
Hello,
I would like to know if it is possible to create a list box, in which I will have all the files in a specific directory. In fact, instead of complete the "Range" for a variable, I would like to "scan" the directory and increase the list... I'm not sure to be clear Thanks |
#2
|
||||
|
||||
Re: List box with specific directory ?
I'm assuming we're talking about Modeling, not Drafting.
Well, AFAIK, the range can be filled with just about anything, including the results of directory scanning. Claus
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
#3
|
|||
|
|||
Re: List box with specific directory ?
Ok
I will try to do that, but do you know how to scan a directory ? Thanks |
#4
|
||||
|
||||
Re: List box with specific directory ?
See Common Lisp documentation on (directory) - http://www.lisp.org/HyperSpec/Body/fun_directory.html.
A while back, I wrote sample code which also uses (directory), see http://www.clausbrod.de/OneSpaceModeling/MacroListDirectory.
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
#5
|
||||
|
||||
Re: List box with specific directory ?
about:
PHP Code:
not tested these lines, only written
__________________
|
#6
|
|||
|
|||
Re: List box with specific directory ?
Hello,
I'm back with this post today...I didn't need before, but now... Quote:
I used these lines, but I have nothing in my listbox...I would like to find all pkg files in a directory... |
#7
|
||||
|
||||
Re: List box with specific directory ?
.. half a year later...
Hi Maximus, try to create TINY test dialogs when you have a problem. Just with that part you have a problem with. And post this tiny thing completely. This saves time , for me and for you. The problem you might have had is a parentheses issue. Well that's typical lisp: Either you have 2 parentheses to less or 3 to much or some/one at the wrong place or something in between PHP Code:
LISP Lost In Stupid Parentheses PS: please use the [code] BB Code when posting sources, then we can see indenting, too.
__________________
Last edited by Wolfgang; 10-15-2008 at 12:02 PM. Reason: bad typo |
#8
|
||||
|
||||
Re: List box with specific directory ?
Truer words have rarely been spoken. Many programming problems which come up in forums like this become blindingly obvious once they are broken down to a few lines of code.
To avoid problems like this, get an editor which matches parentheses and indents Lisp code automatically. With such an editor, you'll be able to detect if there are too many or not enough parentheses just by looking at the physical layout of your code. For example, your version of the :initial-value form looks roughly like this in Emacs: Code:
:initial-value (let ((dir-contents (mapcar 'namestring (directory "c:/*.*"))) (sd-set-range 'dir-range dir-contents) (car dir-contents))) And here's Wolfgang's version: Code:
:initial-value (let ((dir-contents (mapcar 'namestring (directory "d:/*.png")))) (sd-set-range 'dir-range dir-contents) (car dir-contents)))
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ Last edited by clausb; 10-16-2008 at 12:06 AM. |
#9
|
|||
|
|||
Re: List box with specific directory ?
Thanks for your help. I will take care
I have one problem with this code. Now, I have a list of all pkg file, but in the active directory, and not in a specific (c:\*.pkg for example). Last edited by Maximus172; 10-16-2008 at 03:17 AM. |
#10
|
||||
|
||||
Re: List box with specific directory ?
The local test example that I use works as expected.
What does your current code look like, and which version of CoCreate Modeling do you use? Claus
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
#11
|
|||
|
|||
Re: List box with specific directory ?
The version of OSD is 14.50.
I'm confus, it's works..I forgot to specify the good directory. Can we avoid to have the paths of the files, and show in the listbox just the pkg file ? Thanks a lot for your help |
#12
|
||||
|
||||
Re: List box with specific directory ?
The list box displays whatever you feed it. So if you don't want the path to be displayed, feed the list box with just the file names.
Maybe you can also use the special :label syntax for range variables to achieve what you want. See the IKIT documentation on sd-set-range. Claus
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
#13
|
||||
|
||||
Re: List box with specific directory ?
Here's a code example based on Wolfgang's proposal:
Code:
(in-package :my-tools) (use-package :oli) (sd-defdialog 'dir_as_range :variables '((dir-range :range ("dummy") :initial-value (let ((dir-contents (mapcar #'(lambda(path) (list (namestring path) :label (file-namestring path))) (directory "c:/temp/*.pkg")))) (sd-set-range 'dir-range dir-contents) (car dir-contents)) )))
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
#14
|
||||
|
||||
Re: List box with specific directory ?
Quote:
__________________
|
#15
|
||||
|
||||
Re: List box with specific directory ?
Yup, Notepad++ is a great little editor because it knows how to properly deal with Unicode-encoded text files, and because it can highlight Lisp code. It's just so much better than the editors which come with Windows.
However, for any serious Lisp development, I'd still recommend Emacs. For new users, EmacsW32 ( http://www.ourcomments.org/Emacs/EmacsW32.html ) can be an interesting option, as it tries to make it easier for Windows users to learn Emacs. Other important Emacs versions are XEmacs and, of course, [GNU Emacs. Claus
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/ |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|