• Print

Author Topic: Work on DECLARE LIBRARY has begun...  (Read 4557 times)

Galleon

  • Administrator
  • Hero Member
  • *******
  • Posts: 4226
  • QB Forever
    • Email
Work on DECLARE LIBRARY has begun...
« on: November 05, 2010, 04:37:47 AM »
Code: [Select]
DECLARE LIBRARY
    FUNCTION fabs# (BYVAL double#) 'fabs is a C++ function which returns the absolute value of a double precision number
END DECLARE

PRINT fabs(10.8) 'prints 10.8
PRINT fabs(-10.8) 'prints 10.8
This is a very silly example, but it is also a working example in the new version of QB64 I'm developing which supports DECLARE LIBRARY. It's silly because QB64 already has an ABS function, but I'm sure you all get the idea.

The next step is to support the declaration of an actual library which will look more like:
Code: [Select]
DECLARE LIBRARY "opengl"QB64 will the look for 'opengl.lib' and link to it. Because the C++ fabs function is already available, there was no need to specify a library as such, and that method is equally valid in such cases.

DLLs will be specified using:
Code: [Select]
DECLARE DYNAMIC LIBRARY "opengl"
Support for aliasing the C++ function names will also be made possible.

Galleon

  • Administrator
  • Hero Member
  • *******
  • Posts: 4226
  • QB Forever
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #1 on: November 05, 2010, 05:01:51 AM »
This example is for Clippy. ;D
Code: [Select]
DECLARE LIBRARY
    SUB SDL_WarpMouse (BYVAL xoffset&, BYVAL yoffset&)
END DECLARE

SCREEN 13
DO
    _DELAY 1
    x = RND * 300: y = RND * 180
    LINE (x, y)-STEP(10, 10), RND * 100 + 32, BF
    MoveMouse x + 5, y + 5
LOOP UNTIL LEN(INKEY$)

SUB MoveMouse (x AS LONG, y AS LONG)
SDL_WarpMouse x, y
END SUB
And yes, it really did work!
« Last Edit: December 03, 2010, 03:34:28 AM by Galleon »

Clippy

  • Hero Member
  • *****
  • Posts: 14397
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #2 on: November 05, 2010, 05:13:08 AM »
Put a RUSH on that will ya?!  ;D

Actually now we'll need a list of stuff we can do as I'm not familiar with C or DLL's. Is there one to move my cursor one tab space when I accidentally copy a tabbed BAS file into the IDE?

I hope that was an easy fix. Can't have that stuff happening!

I'm sure that this will make some people here very happy! Just try not to make yourself TOO expendable!

Ted
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Galleon

  • Administrator
  • Hero Member
  • *******
  • Posts: 4226
  • QB Forever
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #3 on: November 05, 2010, 05:47:50 AM »
Using libraries can be a perfect solution to some problems. However, libraries tend to be system specific and can be hard/impossible to port.

QB64 will not define/list what is or is not available for the QB64 user to call/access when the library name is omitted. QB64 currently allows access to the SDL functionality not by intention but merely by coincidence.

Furthermore, anyone using libraries is 'on your own' when it comes to support about those particular libraries. QB64 will however, make sure that the process of linking to libraries is documented, consistent and maintained in all future versions of QB64.

Ultimately the question should be...
Q: Can QB64 already do what I want without using a library?
A: Yes. >Don't use a library.
A: No. >Use a library.
QB64 is a very inclusive and eclectic language so there is a good chance what you want to do can be done (or will be able to be done in the future) with native QB64 commands without the need for libraries.

DarthWho

  • Hero Member
  • *****
  • Posts: 3349
  • Timelord of the Sith
Re: Work on DECLARE LIBRARY has begun...
« Reply #4 on: November 05, 2010, 06:19:08 AM »
Cool looks very interesting Galleon.
Rassilon: My lord Doctor; My lord Master; My lord DarthWho
The Doctor and the master at the same time :WHAT!?!?!

FastMath 1.1.0 released: http://dl.dropbox.com/u/12359848/fastmath.h

Clippy

  • Hero Member
  • *****
  • Posts: 14397
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #5 on: November 05, 2010, 06:37:35 AM »
Well, knowing people like I do, there will always be some people that think their library should work in QB64 and will question it's abilities anyhow. I'm gonna take a wait and see on this stuff as I have not had to use all of what QB64 offers already.

Ted

PS: Got a function to create a custom mouse pointer on the fly? I'm gonna try to make some CUR files soon.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

unseenmachine

  • Hero Member
  • *****
  • Posts: 3248
  • A fish, a fish, a fishy o!
Re: Work on DECLARE LIBRARY has begun...
« Reply #6 on: November 05, 2010, 10:35:46 AM »
Quote
Got a function to create a custom mouse pointer on the fly?

Could you use _MOUSEHIDE and put an image where the mouse is?
UnseenGDK Download : http://dl.dropbox.com/u/8822351/UnseenGDK.bm
GDK Tutorial : http://dl.dropbox.com/u/8822351/UnseenGDK_Tutorial.doc
VQB02 : http://dl.dropbox.com/u/8822351/VQB02.zip

codeguy

  • Hero Member
  • *****
  • Posts: 3339
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #7 on: November 05, 2010, 10:57:42 AM »
Quote from: unseenmachine on November 05, 2010, 10:35:46 AM
Quote
Got a function to create a custom mouse pointer on the fly?

Could you use _MOUSEHIDE and put an image where the mouse is?
i have been able to make an image follow the mouse, so it should be a piece of cake, and don't forget to subtract half image width from mx and half image height from my when placing cursor as _putimage starts from upper left corner!
do
cls
do while _mouseinput
mx=_mousex
my=_mousey
loop
_putimage...
_display
_limit
loop
if you're doing this on a solid BG, it'll be easier by a couple steps, but easy nonetheless.
and i got JUST the right image for ya too! http://www.qb64.net/forum/index.php?action=dlattach;attach=5;type=avatar
« Last Edit: November 05, 2010, 11:02:50 AM by codeguy »
i want a piece of 3.141592653587932386

Clippy

  • Hero Member
  • *****
  • Posts: 14397
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #8 on: November 05, 2010, 11:02:37 AM »
I was just trying to get that AX = 9 Interrupt function is all. I can make my own CUR files as soon as I finish my ICON creator. All I wanted was a quick way to do it with an Interrupt demo I have.

I figured it might be in SDL too.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Cyperium

  • Hero Member
  • *****
  • Posts: 3100
  • Knowledge is good, but understanding is better
    • Cyperium
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #9 on: November 05, 2010, 11:13:27 AM »
Thanks Galleon :) The possibilities are endless!
Venture - New Prototype, QB64 Editor v1.95b (now linux/mac compatible).

codeguy

  • Hero Member
  • *****
  • Posts: 3339
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #10 on: November 05, 2010, 11:23:11 AM »
Quote from: unseenmachine on November 05, 2010, 10:35:46 AM
Quote
Got a function to create a custom mouse pointer on the fly?

Could you use _MOUSEHIDE and put an image where the mouse is?
gotta agree with ya about that. i think it'd be easier than the interrupt method, but i think he wants to keep his demo 100% qbxx compatible.
i want a piece of 3.141592653587932386

Clippy

  • Hero Member
  • *****
  • Posts: 14397
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #11 on: November 05, 2010, 11:25:26 AM »
Hey, they gotta get done sooner or later. Besides, none of the WIKI examples run completely yet. One needs BYVAL too.
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

codeguy

  • Hero Member
  • *****
  • Posts: 3339
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #12 on: November 05, 2010, 11:32:50 AM »
i think the other thing that would be nice is being able to use different data types for a standard routine (ONE sort method for various kinds of data) and even COOLER would be:
type stuff
a as integer
x as string * 93
end type
dim array(0 to 93) as stuff
Sort array().x,0,93
sub Sort (a() as _UTYPE,start,finish)
end sub
one sort method, one compare method and sort by any element of a() regardless of type i think this can be done in c and _UTYPE to indicate udt. this is another feature i don't think any other programming language has. of course, the technical complexity might be sort of a big pain in the ascii! this would be useful because it would save writing TONS of extra sorts for each data type. and it could even be incorporated into a standard function library. and if ya can do this, you can find a way to print all the elements of stuff (udt) without creating a specific sub to do it, another feature i don't think the other basics have.
« Last Edit: November 05, 2010, 11:50:47 AM by codeguy »
i want a piece of 3.141592653587932386

codeguy

  • Hero Member
  • *****
  • Posts: 3339
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #13 on: November 05, 2010, 11:45:28 AM »
Quote from: Clippy on November 05, 2010, 11:25:26 AM
Hey, they gotta get done sooner or later. Besides, none of the WIKI examples run completely yet. One needs BYVAL too.
why not just use a temp variable of the same type you don't wanna have changed?
sub a(b,c)
TempB=b
do all ya wanna do to TempB here
end sub
i want a piece of 3.141592653587932386

Galleon

  • Administrator
  • Hero Member
  • *******
  • Posts: 4226
  • QB Forever
    • Email
Re: Work on DECLARE LIBRARY has begun...
« Reply #14 on: November 05, 2010, 02:37:12 PM »
The most significant change to QB64 in ages is coming, and we are talking about changing the mouse cursor...

Gotta love it,
Galleon

  • Print