I’m evaluating Xojo for some upcoming projects. To do this I’m creating a dynamic library on OSX/Linux/Windows that implements a stack. I’m then tying a Xojo GUI interface into it. The object of this is to determine the level of access to dynamic libraries and the ease of use.
The question is, where’s the best place to put the following CONST and Soft Declares to make the functions in my dylib available to the app? I can certainly add these to the controls I create but I was hoping there was a better option where I can just declare them once.
Soft Declare Function stack_create lib dylibLocation () as Ptr
Soft Declare Function stack_push lib dylibLocation(stack as Ptr, value as Ptr) as Ptr
Soft Declare Function stack_pop lib dylibLocation(stack as Ptr) as Ptr
Soft Declare Function stack_shift lib dylibLocation(stack as Ptr) as Ptr
Soft Declare Function stack_unshift lib dylibLocation(stack as Ptr, value as Ptr) as Ptr
Soft Declare Function stack_clear lib dylibLocation(stack as Ptr) as Ptr
Soft Declare Function stack_clear_and_destroy lib dylibLocation(stack as Ptr) as Ptr
You can add them to a module and they’d be available to your entire app. If you make the module an external one, you can reuse the module in multiple projects.
Yes, exactly. Xojo doesn’t use header files, but you can create your own module (name it “myDeclaresModule” if you want) and use it in all your projects. You can make it external by right-clicking on it and choosing “Make external” and then import it into other projects as an external module (available on the File menu if you hold down the Alt key) and reuse the same module in multiple projects.
All methods, constants, and properties declared in a module are global, so they’re available to your entire application. That should do what you want.
So, the real answer is I don’t have to write the code I have in my first post. I get the equivalent when using the GUI to create a module and external methods within that module. Nice.
Also, it appears to be the case when creating external methods Xojo will accept either a library name or a full path to the library. My final question… could I use a constant or a computed variable when specifying the library?
I want to use a constant for the library path. I can put the full path for the Lib in when I create the external method. It’s not letting me use a constant I have declared which has the same path as it’s value. Is there a special syntax required to reference it?
Hmm, it seems that the IDE doesn’t allow constants in external methods even though the Declare syntax allows it in code. Unless someone knows a workaround I’d say this would be a good feature request.
How would I go about reporting this? I found another minor bug earlier today. Clicking the feedback icon asks me to install and then download… but doesn’t seem to do either.
Thanks! Btw, I was just searching the site looking for that. In the FAQ it just says I can login to Feedback using my Xojo username and password. It might be handy to have this link in there, especially if the Feedback icon in the app isn’t working correctly.
I just discovered that if the first character in the library name TextField is a “#” character then sometimes the IDE interprets everything after the # as a constant. But it’s very unreliable and half the time the compiler raises strange errors. Is the IDE supposed to allow “#ConstantName” in the external method editor’s library field?