PLEASE HELP ME :)

Post your coding questions such as 'how to' here.
Post Reply
Chopepo
Newcomer
Posts: 4
Joined: Mon Aug 03, 2009 3:58 am

PLEASE HELP ME :)

Post by Chopepo » Mon Jan 04, 2010 2:57 am

Hi:

I know how is to create a DLL to call coolbasic as this to function.

Can I create a DLL taken to control the parallel port for example?
How are the memblocks?

and finally ...

How do I use the INCLUDE command?
I tried to use the include but when I compile I get an error.

Your help will be very useful to me.
Thank you very much in advance.

Bye.

User avatar
valscion
Moderator
Moderator
Posts: 1585
Joined: Thu Dec 06, 2007 8:46 pm
Location: Espoo
Contact:

Re: PLEASE HELP ME :)

Post by valscion » Mon Jan 04, 2010 5:02 am

Chopepo wrote:How do I use the INCLUDE command?
I tried to use the include but when I compile I get an error.
As for the other questions, I can't help you. But I'll give a try for this one; include basically includes, adds the insides of another textfile (like a .cb file) to your current program. This way you can easily chop your code to smaller bits and therefore help reading and creating it.

For instance, you could have a sourcecode in functions.CB file looking like this:

Code: Select all

Function MyFunction( txt$ )
  MakeError "This is MY function!"+Chr(10)+Chr(13)+txt$
EndFunction
and then you could have your actual sourcecode and mainloop in game.CB file looking like this:

Code: Select all

Include "functions.CB"

Repeat
  If KeyHit(cbKeyReturn) Then MyFunction( "Return pressed!" )
  Text 0, 0, "Press RETURN"
  DrawScreen
Forever
Can you see the first line? It adds the functions.CB file to the code that goes to CoolBasic Compiler which creates the final EXE file. So basically it's the same as if you would write it all to one file, looking like this:

Code: Select all

Function MyFunction( txt$ )
  MakeError "This is MY function!"+Chr(10)+Chr(13)+txt$
EndFunction

Repeat
  If KeyHit(cbKeyReturn) Then MyFunction( "Return pressed!" )
  Text 0, 0, "Press RETURN"
  DrawScreen
Forever
After you get hundreds of lines of code, chopping up the code to smaller pieces to different files will help you a lot. And that's what the INCLUDE command is for :)

I hope this clears things up for you ;)

Later!
cbEnchanted, uudelleenkirjoitettu runtime. Uusin versio: 0.4.1 — Nyt myös sorsat GitHubissa!
NetMatch - se kunnon nettimättö-deathmatch! Avoimella lähdekoodilla varustettu
vesalaakso.com

User avatar
Zero
Lead Developer
Lead Developer
Posts: 712
Joined: Sun Aug 26, 2007 2:30 pm
Location: Helsinki, Finland
Contact:

Re: PLEASE HELP ME :)

Post by Zero » Mon Jan 04, 2010 9:58 am

To control serial port (and the like) via CoolBasic, you'll first need to create a DLL file in C/C++ (functions must be declared with "extern C" to prevent C++ name mangling). Inside your DLL you write the necessary program logic to control the serial port; the DLL only exposes an interface for CoolBasic. You mentioned that you're already familiar with calling external code from CoolBasic, so I assume the real problem for you is to create the actual serial port controller. In this I cannot help you, but you use memblocks in exactly the same way you would otherwise pass data back to a CoolBasic program. It could be something like a poller function you'd call regularly to receive serial port state (and optionally the other way around i.e. pass data over through the serial port).
CoolBasic henkilökuntaa
Johtava Suunnittelija
CoolBasic V3, CoolBasic Classic

http://www.coolbasic.com/blog

chopepo - :)

Re: PLEASE HELP ME :)

Post by chopepo - :) » Mon Jan 04, 2010 8:04 pm

Thank you very much, very clear to me.

:D

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest