Create lots of properties

Hi!

I need to create “100” properties on IDE

is there a way to “copy/paste” instead of creating one by one?

Thank you!

Alex

Sure, you can copy-paste properties in the IDE, but the will be automatically suffixed, e.g. if you copy MyProperty and paste it, the new one will be MyProperty1.

Maybe arrays or dictionaries would be more manageable?

Usually the way to go in most cases.
People creating lots of variables and properties right from the design usually are missing something.

Out of curiosity, why do you need to create so many properties for a single object ?

I don’t know yet how to create dictionaries the way i need.

I have a project, a global module with a lot of methods. one of this methods will set a lot of variables. i want to put a dictionary property on this global module… (i think it’s clever) but i don’t know how/where to put the “dim mydict as new dictionary” to create it…

this is a sample…
teste.xojo_binary_project.zip (4.3 KB)

SInce the dictionary is in a module, you can instantiate it from anywhere, for example in App.Open. If the module has a lot of app-wide stuff you could instead have a method in the module called “Init_System” or something like that that instantiates and initializes everything, and call that method from App.Open.

how instantiate the myDict, inside myModule on App.open, or window1.open?

Here’s one way of doing it. Though, I’m not sure what value data-type you need. I used an Integer in my example, but a Variant is fine too.

2 Likes

You don’t need to “Dim” it because it’s declared in the IDE, so in App.Open you could just write

mMyDIctionary = new Dictionary

But the way you show, checking for Nil and instantiating it if it is, is actually more elegant since you have single entry points for setting and getting values.

2 Likes

last question:

is it possible to add a class inside a module?

there are a lot of informations about a company: name, address, etc. i’m getting this informations thru an API, and then i’ll need to fix/normalize some of them, and after this, insert/update on a database.

Since you will persist the data, you do not need a large amount of properties on the object for the company. All you need to do is query the database and temporarily save the information in a dictionary as you agreed to.

Absolutely, and Modules have interesting properties, from Documentation:

A module can contain members (methods, properties, etc.) that are global to your project. It can also contain project items, such as classes and even other modules, allowing you to control access and scope of your project items.

Emphasis is mine.

Xojo provides many ways to reach your goals. Just ask here on the Community!

on a clean project, it works:

but on my actual project, it do not allow me to add a class inside a module…

… the module cannot be external… only internal to accept class

and then i cannot make it external…

Your “AleMaxModules” is external. You can’t add a class to something external.

1 Like

where can i ask to add this functionality?

in a feedback report, clic “issue” at the top of the forum
but don’t worry it’s already been asked years ago, if not decades…
I heard it’s “complicated” …

or centuries…

yeah… i know. the “issue” has a trigger that sends it to void

thank you all for your help!

Alex

Hi!

Could you ask developers to look onto it?

https://tracker.xojo.com/xojoinc/xojo/-/issues/60663

Thank you.