Thank you Chris.
Very useful and clear. I'll try that solution, which seems to be the most simple, on the Squeak side.

In fact I've been experimenting and prototyping both in Squeak and Pharo. It may be a waste of time and effort, but it is useful for me, as a beginner, to learn which are the best tools in each situation. I guess in the end I will opt for a GUI built with Pharo Spec2, because it was always difficult for me to understand how to use pluggable morphs (lists, text edits, etc.).

I can anticipate several future problems, and I'll take this opportunity to raise another question:
When I finally have the application working, I preview I'll have a few thousands cards (sets of WorkCards) and a few hundreds card (set of AuthorCards), and also a few dozens of tags, all related between them (instances of WorkCards will have references do instances of AuthorCards, and so on). In your experience, in such a situation, can I get away with the image or should I get into more complicated deals to guarantee secure persistence of data between sessions? I know a few pages about the subject, but the most interesting ones (Ramon?) seem outdated or inconclusive.
As usual, it is not that easy to find useful documentation for most frameworks in Squeak (for example, FileDictionary).

Rui Viana Pereira


Chris Muller <asqueaker@gmail.com> escreveu no dia sábado, 28/10/2023 à(s) 21:57:
You mentioned you have thousands of files.  #directoryTreeDo: is the most-efficient approach performance-wise (including the least amount of garbage production), but also the simplest in terms of code length and complexity.  It was designed to handle this exact use-case.

From the directory returned from your DirectoryChooser, you can write:

    rootDirectory directoryTreeDo:
       [ : path |
       "... do your work with Authors and Cards using 'path',
       which is a Collection of DirectoryEntry's ..."  ]   

The first element of the 'path' OrderedCollection will always be the DirectoryEntryDirectory for myDirectory.  The subsequent items represent the path to the current item you wish to process.

It's an object-oriented design that provides the user with the most information to support the broadest range of use-cases, while being simple and efficient.

You might consider attach the entries themselves straight to your Card objects if you want!  That would capture not only the directory location and filename, but the "size", "lastModified" date, too.



On Tue, Oct 24, 2023 at 1:27 PM <ruivianapereira@gmail.com> wrote:
I'm not a programmer of any kind or language; I'm an amateur.
I have a personal digital library with thousands of documents, which are useless unless I manage to classify them.
I thought it would be an easy task with Squeak, since it is a quite simple problem, but I'm lacking some solutions, as a beginner.
My general cenario:
I made a class, lets call it card, to hold information about each work, each author, their location on disk and the relations between authors and works:
Object>>#Card (instance var : name, location, notes, tags ... )
                   >>Author
                   >> Work
Object>>#MyLibrary (instance var : authors <aCollection>, works <aCollection>, myLibraryBase <aPath?>)

Than I initialize #MyLibrary instances with a UIManager directoryChooser to establish from the begining a reference to the directory where all the relevant files are.
But, because it is thousands of files, I would need an automatic method to «scan» all the relevant files in the directories and subdirectories. Meaning: the method should make a collection of all the files, recursively in subdirectories, and for each one it should create a card.
And that's where I got stuck: how do I scan recursively the subdirectories?
Most of the new tools are quite confusing for me, namely classes and tools to deal with files.

Can anyone point me in the wright direction, please?
Thanks
_______________________________________________
Beginners mailing list -- beginners@lists.squeakfoundation.org
To unsubscribe send an email to beginners-leave@lists.squeakfoundation.org
_______________________________________________
Beginners mailing list -- beginners@lists.squeakfoundation.org
To unsubscribe send an email to beginners-leave@lists.squeakfoundation.org