constants in module

Two questions concerning constants in a module ;
When I add one constant, it seems to take it OK. Do I have to create another page in the module to add another constant?
How do I declare global counters in the module, such as i, j, k as integer. Do each of these require a separate page in the module or should I declare them in each method of the project?

I have assumed (nearly always a bad thing to do) that the + and - circles on the module constant page are for making the stated constants available for other platforms, not for adding another constant to the page. How correct is that?

In addition, each global method in the module is in a page all to itself. As I generally print all my project code when the .exe has been created, can I only print one method per page?

Many years of Visual Basic programming seems to have locked stuff in my head that I wish would work in Xojo, but doesn’t. I want to learn Xojo as the latest versions of VB.Net seem to have exceeded my programming pay grade, but I have not been able to find answers (so far) to the questions stated above.

Tanks for any light you can shine on an old geezer who loves to write useful programs but can’t seem to find answers in the online documentation.

Joe

[quote=317135:@Joe Williams]When I add one constant, it seems to take it OK. Do I have to create another page in the module to add another constant?
How do I declare global counters in the module, such as i, j, k as integer. Do each of these require a separate page in the module or should I declare them in each method of the project?
[/quote]

Yes, you’ll have to create another one other. The item in the Navigator (the list on the left) lists your constants. The constant editor allows you to customize that per language and/or platform. This last capability is handy for Dynamic string constants where you might have “End” in English but “Finis” in whatever language that is.

One word of caution. Global counters should be named MUCH better than i, j, k, etc. Those are fine within a loop in a method but global constants should be named something useful like iCountOfMyItems, or jMaxCount. I’ve discovered in my many years of Xojo programming that the number of global properties should be minimal so if you find yourself doing a LOT of global variables you might want to encapsulate into classes.

You can print the entire project or individual objects (including modules).

Besides the Language Reference (via the Help Menu), there are a number of videos on YouTube that you might find useful. I have over 62 hours available to subscribers at http://xojo.bkeeney.com/XojoTraining/. That’s about 200 videos covering a wide range of topics including 2 start to finish desktop applications, and 1 start to finish web application.

Mr. Bob - thanks for your info and suggestions, but I thought of one more quickie:
I have a method in the module which I want to fill in text boxes on a form (or Window) . I haven’t been able to find the command (or even f it exists) which tells the module method which form and which text box. In VB it was “With fmAction” and .txtAmount.text =. Just tell me where I can find the command - I’m happy to look up the details.
Thanks Again

Well, I wouldn’t do it the way you’re proposing but whatever. Iterate through the Window array until you find the window type you want and then cast it and away you go.

for i as integer = 0 to WindowCount-1 if window(i) isa MyWindow then dim w as MyWindow = MyWindow(window(i)) //access the controls on MyWindow w.textField1.text = "Some text" w.checkbox1.value = SomeBoolValue end next

I would spend some time reading through the Xojo User Guide and looking at the YouTube videos and stop trying to do it the VB way. Embrace the Xojo way and you’ll be much happier in the long run.

Just pass a reference to the window as an argument to your method.

For instance, if you have a method named “ProcessMyFields” in a global module and you have MyWnd as MyFancyWnd:

Sub ProcessMyFields (WndToProcess as MyFancyWnd)

Then, inside ProcessMyFields you can access WndToProcess.MyTextField.Text or whatever.