Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Turning functions into a dll?

Author
Message
BaZko
20
Years of Service
User Offline
Joined: 24th Sep 2004
Location:
Posted: 23rd Jan 2005 09:54 Edited at: 24th Jan 2005 02:21
Im making a set of commands/functions in dbc for dbc and i was wondering how could i turn them into a dll so they can be loaded it in dbc?

Join the new years contest!
BaZko
20
Years of Service
User Offline
Joined: 24th Sep 2004
Location:
Posted: 24th Jan 2005 02:21
Please help.

Join the new years contest!
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 24th Jan 2005 04:06 Edited at: 24th Jan 2005 04:10
What I do is instead of making a dll, I just make a .dba file with only the functions. Then I use the #Include command in the main .dba file. Then you can call any of the functions that you want in the main .dba file.

Example:

File: Functions.dba

Function ClickBox(Left,Top,Right,Bottom,Click)
Box_Clicked=0
If MouseClick()=Click and MouseX()=>Left and MouseY()=>Top
If MouseX()=<Right and MouseY()=<Bottom
Box_Clicked=1
EndIf
EndIf
EndFunction Box_Clicked

File: Main.dba

#Include "Functions.dba"
Sync On : Sync Rate 20
Show Mouse

Ink Rgb(255,0,0),0 : Box 0,0,100,100
Ink Rgb(0,255,0),0 : Box 200,0,300,100
Ink Rgb(0,0,255),0 : Box 400,0,500,100

Do

If ClickBox(0,0,100,100,1)=1 Then Print "You Clicked The Red Box"
If ClickBox(200,0,300,100,1)=1 Then Print "You Clicked The Green Box"
If ClickBox(400,0,500,100,1)=1 Then Print "You Clicked The Blue Box"

If ReturnKey()=1 Then End

Sync
Loop

I tried the code, and it works, so let me know if it helped.

Also, I've never used dll files, but I know that if you create a .dba file and then change the extension to .dll the file becomes one, but I never use dll files, so I don't really don't know anything about them.
Jake Blues
20
Years of Service
User Offline
Joined: 19th Jun 2004
Location: United States
Posted: 24th Jan 2005 08:41
I have not tried it but Underworld 1020 could be right. You probably could just change the extenstion to .dll and then include it like you would with a .dba. It would hold the same stuff but be a different extenstion.

Don't let life get you down, it will only get better.
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 24th Jan 2005 10:13
Thats what you should do, except the changing it to .dll part. That's just retarted no offense. Why would you want to change it to .dll if it worked in .dba anyways?

Hi
Jake Blues
20
Years of Service
User Offline
Joined: 19th Jun 2004
Location: United States
Posted: 25th Jan 2005 07:41
I don't do it, it was just an answer to his topic. I would not turn it into a .dll, but thats the only way I know.

Nice signature Mattman.

Don't let life get you down, it will only get better.
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 26th Jan 2005 05:36 Edited at: 26th Jan 2005 05:36
dlls are made in C++. if you know how to make functions in C++, and have a compiler that supports dll making, for example Dev-C++ or Visual C++, you can select dll in the project options. calling dlls, however, does not require C++ knowledge, but it could help. simply changing the dba file's extension to dll wont work. someone correct me if i am wrong.
ill show exactly how to make one soon, hopefully.

coffee + monkeys + creativity = games
Operation Pineapple - Multiplayer FPS WIP
empty
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 26th Jan 2005 05:52 Edited at: 26th Jan 2005 05:53
Quote: " dlls are made in C++. "

DLLs are made in Delphi.
Well, and in C(++) too. And in Pure Basic. And in Power Basic. And in Free Pascal.


Play Nice! Play Basic! Version 1.06
BaZko
20
Years of Service
User Offline
Joined: 24th Sep 2004
Location:
Posted: 26th Jan 2005 09:27
im making a plugin so if i give the code ppl can steal it.Plz help me make it a dll.

Join the new years contest!
Sol462
20
Years of Service
User Offline
Joined: 12th Sep 2004
Location: playing with the spazookeedoo
Posted: 26th Jan 2005 11:12
@empty:
whoa. you learn something new every day. i dont see darkbasic in that list though

so you're trying to keep people from stealing your code? bummer, id have said you put the code on the forum and someone convert it into a language that dlls are made of.

coffee + monkeys + creativity = games
Operation Pineapple - Multiplayer FPS WIP
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 27th Jan 2005 04:08
Can't you just save the code as a .exe file?
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 4th Feb 2005 01:23
Yeah, but then you can't #Include it.

Try making a program that gets the user to choose their code file and where DarkBASIC is, then temporarily write the (secret) library code to a .DBA file somewhere.

Add #include "library.dba" at the top of their code (automatically) or whatever, then compile their program as an EXE, or run it depending on what option they choose. Roughly a few seconds after DarkBASIC has started running the program or compiled the EXE, it will be safe to delete the temporary library.dba file, as DarkBASIC will have already loaded the file into memory.

That's a small-scale solution. Obviously, the program would know what to put in library.dba, and the code of the library file would be hard-coded into it. I recommend you store the file as an array of bytes (the ASCII codes) rather than as normal Strings, as otherwise the EXE can be hacked really easily.

This could be quite easy to get around, but it should do for a couple of newbies / non-PC literates.

Avatar - white cat in a snowstorm. Look closely.
Jake Blues
20
Years of Service
User Offline
Joined: 19th Jun 2004
Location: United States
Posted: 4th Feb 2005 06:42
Another way is to NOT release the code on the internet. When you make a final executable, it saves not only media, but .dba files. This would take your external code and save it into an exe with the main program, just like c does.

Don't let life get you down, it will only get better.

Login to post a reply

Server time is: 2025-05-25 08:39:28
Your offset time is: 2025-05-25 08:39:28