Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do i make libaries, VERY n00bish question i know, but...
#1
I'm sorry for asking such a n00bish question

I am trying to make a simple libary.

Basically i want to turn this into a libary file

Code:
DECLARE FUNCTION stall (sleepertime AS INTEGER)

FUNCTION stall (sleepertime AS INTEGER)
    
    SELECT CASE sleepertime
    
CASE IS > 0
    
    T = TIMER + sleepertime
      WHILE T! <= T
        key$ = INKEY$
        T! = TIMER
        IF key$ <> "" THEN EXIT FUNCTION
      WEND

CASE ELSE
      
       WHILE key$ = "":key$ = INKEY$: WEND
    
END SELECT        

END FUNCTION
2 problems

1) i do not know what the .bi file would look like
2) how do i actually turn this into a libary

I'm sorry for asking such a n00b quetion, but a google search came up blank
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#2
See the examples/lib for more details.

The inc file should contain only function prototypes (DECLARE ...) and TYPE's and CONST's. That's not a rule, you could actually include function bodies and main module code (unlike in QB). Also, if you add the #inclib directive, you won't have to add the lib to fbc's command-line.

So for that case it should be:

mylib.bi:
Code:
#inclib "mylib"

DECLARE FUNCTION stall (sleepertime AS INTEGER) AS INTEGER

In mylib.bas:
Code:
#include once "mylib.bi"

... the same code you posted without that DECLARE FUNCTION ...

Compile mylib.bas as: fbc -lib mylib.bas

The libmylib.a file will be created.

Now you can use the library in some module like:

test.bas:
Code:
#include once "mylib.bi"

stall( 1234 )

Compile it as: fbc test.bas

Nothing else is needed, libmylib.a will be added automagically..
Reply
#3
Thanks! Thats a great help. I'll go shoot myself for deleting the examples folder.

EDIT: Is this lib usable with c++ (if i port the .bi to c)
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)