Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Paul on March 08, 2007

Title: noob questions.
Post by: Paul on March 08, 2007
Hi, Ive got some noob questions.

1. How do i get rid of the window(the one whch always come up when i run anything)

2. Is it possible to get the commandline parameters in freebasic?

3. Is it possible to compie dlls with freebasic?
Title: Re: noob questions.
Post by: rdc on March 08, 2007
Yes, to all of those.

1) Compile with -s gui to get rid of the console.
2) You can get the command line parms using the Command function. From the help:

Code: [Select]
''
'' command-line arguments example
''

     Print "exe name= "; Command( 0 )

     Dim argc As Integer, argv As String

     argc = 1
     Do
         argv = Command( argc )

         If( Len( argv ) = 0 ) Then
             Exit Do
         End If

         Print "arg"; argc; " = """; argv; """"

         argc += 1
     Loop

     If( argc = 1 ) Then
         Print "(no arguments)"
     End If
     Print "The complete list: ";Command

3) Compile with -dll to create a DLL.

You can get the current docs at the FB wiki (http://www.freebasic.net/wiki/wikka.php?wakka=FBWiki).
Title: Re: noob questions.
Post by: ferris on March 08, 2007
You beat me to this one :P
Title: Re: noob questions.
Post by: Paul on March 08, 2007
Thx for the quick answer, helped allot:)
Title: Re: noob questions.
Post by: Paul on March 08, 2007
One more question how, a little more exactly do i create a dll.
Title: Re: noob questions.
Post by: Paul on March 08, 2007
I've got this code and its compiling to a dll but i cant get it to work.

Code: [Select]
#include "windows.bi"
option explicit
declare function testfunc(in as string) as integer

'testfunc("hello")

function testfunc(in as string) EXPORT
    return messagebox(0,in,"test",0)
end function

I'm using this code in Blitz to test it
Code: [Select]
bank=CreateBank(4)
Print CallDLL("dll.dll","testfunc@4",bank)

changed the code to and that works, but if i send a bank iwth anything other than 0 it craches

Code: [Select]
#include "windows.bi"
option explicit
declare function testfunc lib "dlltest" alias "testfunc" (in as string) as integer

'testfunc("hello")

function testfunc(in as string) EXPORT
    return messagebox(0,in,"test",0)
end function
Title: Re: noob questions.
Post by: Shockwave on March 08, 2007
Damn, that's 2 questions that you posted today that I don't have a clue! Hopefully someone can help. Sorry.