|
Post by bulletfox on Oct 24, 2023 23:29:01 GMT
Hi all! I'm new to QB64 entirely, and have decided on undertaking an ambitious project right out of the gate. I was wondering if I could somehow point to a function, so that I can make my psuedo-object orientated design work. Something akin to
Sub testRoutine()
End Sub
DIM test AS _MEM test = _MEM(testRoutine(0))
|
|
|
Post by bplus on Oct 24, 2023 23:49:16 GMT
|
|
|
Post by bulletfox on Oct 24, 2023 23:53:28 GMT
Well, THAT'S an unfortunate end to my hopes there. Such a shame too, I liked QB64's built-in IDE... Ah well. Thanks for the reply!
|
|
|
Post by bplus on Oct 24, 2023 23:56:02 GMT
Well I wasn't done looked up a Pointer discussion in FB see link above.
|
|
|
Post by bulletfox on Oct 25, 2023 2:42:33 GMT
bplus Well, that's interesting, thanks for linking that! I already knew that function pointers did exist in FB, I just wanted to try a different dialect to FreeBASIC. I miss PDS, FreeBASIC just does not have the same feel of that language. A bit off topic, but I'm a little curious. What is your role in QB64? Just moderator or are you a contributor to the code that I missed?
|
|
|
Post by bplus on Oct 25, 2023 10:05:58 GMT
Yeah just a moderator to keep spammers at bay, help newbies or retired returnees get going with a newer QB and general Basic pointer to fans when I might know something that could be of help. I wish I were a contributor to the QB64 project but don't know C++ and I hear the code is a nightmare anyway
|
|
|
Post by aurelvz on Oct 25, 2023 18:29:26 GMT
function pointers are in Oxygen basic
|
|
|
Post by Ultraman on Oct 26, 2023 12:06:29 GMT
bulletfox You technically can do function pointers but not directly like that. It's a bit janky but can be done. Here is one way to do it. I wrote this code a couple years back for doing threading in QB64 on Windows. It uses a callback function. With this one, you'll want to look at the C++ code block and check the MyThreadFunction& function. Here is another way with code that I also wrote a couple years ago. It's big, so please forgive me if you are unable to quickly figure it out. You'll want to pay attention to the block that says You'll also want to look at the taskdlg.h file. You'll pretty much always need a header file (.h) in order to take advantage of callback functions and/or function pointers in general. If you notice, in both instances, I had to declare the function name in the header as the way that QB64 would interpret a function's name. Function MyThreadFunction&(lParam As _Offset) becomes Function TaskDlgCallback%& (hwnd As _Offset, msg As _Unsigned Long, wParam As _Unsigned _Offset, lParam As _Offset, lpRefData As _Offset) becomes As you can see, it can be a little crazy and confusing. If I remember correctly, after you make your function, look for a file called "main.txt" in your QB64 folder (easiest way to find it would be to use the search function in File Explorer or use FART). That contains your code converted to C/C++. You can then copy the function's signature out of that. I'd be happy to help you out with this.
|
|
|
Post by bulletfox on Oct 30, 2023 21:34:40 GMT
bplus Well, you certainly seem to be doing a good job! Thank you for your diligence. aurelvz Outside of my scope, but thank you anyways. I'll keep an eye on Oxygen BASIC, but I think I'm just going to recede back to FB for what I need. Ultraman While an impressive feat, that is way too much effort to do the couple hundred times I want to achieve this, unfortunately. Not to mention my head, which is spinning just trying to read the second one. I appreciate the outreach though, and if I have any simpler projects, I might try to take advantage of this.
|
|
|
Post by Ultraman on Nov 1, 2023 17:59:06 GMT
You're welcome. I, too, find it to be burdensome in my larger projects but oftentimes the result is great enough to ignore the pain needed to get there. With those function pointers and callback functions, you are able to do native Win32 GUIs using QB64. It can be quite a nice experience. But definitely reach out to me if you ever are considering moving forward with function pointers / callback functions.
|
|