March 28, 2024, 02:46:57 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


adding functions to command pak

Started by ZeroDog, February 06, 2010, 07:21:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ZeroDog

Is anyone familiar with creating command paks?  I have been trying to put my own functions written in EBasic into a command pak, unfortunatly I have not been able to do it successfully.  I have $INCLUDE'd, GLOBAL'd, EXPORTED, and tried everything else I can think of...  does anyone know how you go about it?  

fasecero


  • Create a library with the desired functions and place the *.lib inside the directory "EBDev \ libs".

  • Declare the functions in a *.incc file located inside the directory "EBDev \ bin". The format of this file can be inferred by studying "ebstd.incc"  located in the same directory (especially the header and the $command keyword).

I had never tried it, so I'm not sure if I'm alright :)

LarryMc

February 06, 2010, 09:38:24 PM #2 Last Edit: February 06, 2010, 09:52:25 PM by Larry McCaughn
Yes, that is the way to do it.
By header he means this:
'*NAME|Emergence BASIC core
'*VERSION|1.737
'*REQUIRE|ebstd.lib
'*HELPFILE|usersguide.chm,EBASIC Users Guide

give it any name you want
give it any version you want
give it the name of your lib for the REQUIRE
if you have a helpfile then list the name of the .chm file followed with , and then the name you want to appear in the IDE help file dropdown.

A side note about the last item.
If you have other help files you would like to use from inside the IDE you can create an .incc file for each of them and they can be opened from the IDE help menu.

Note: when adding .incc you can't see what you added until you close and then reopen the IDE.

Neat trick I use:
HELPFILE doesn't have to be a helpfile

I created a colorpicker.exe (along with some others) so I could pick my colors when working on a GUI.
I created an empty .incc file and put the following line in it:

'*HELPFILE|c:\EBDEV\projects\colorpicker.exe,ColorPicker
Now when I need to pick a color I just click on Help/ColorPicker and it pops up.

WARNING: the thing you have to be careful of is duplicating any existing function/command names that exist in any of the current libraries that the linker uses and any that it may use in the future.

If you do what you are wanting to do and you use function names that are simple and something Larry might use in the future your program may not recompile correctly with a future release of EB.  So be sure to use function names that no one else would pick.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ZeroDog

Quote from: fasecero on February 06, 2010, 09:10:59 PM

  • Create a library with the desired functions and place the *.lib inside the directory "EBDev \ libs".

How do you go about making a .lib from EBasic functions?

LarryMc

February 06, 2010, 10:46:36 PM #4 Last Edit: February 06, 2010, 11:07:12 PM by Larry McCaughn
create a new project; make sure you select the "compile to lib" option.
create a file and add it to the project
add your functions to the file making sure you do global sub mysub(.........)

compile your project
it creates the .lib file
put it in your EBDEV\libs directory

then create your .incc file as described above put it in the EBDEV\bin directory

close EB and reopen EB

then write your program, calling one of your functions

if you get an error then you might have to use use$ "mylib.lib"  but I think the incc should take care of that for you.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

the other way to use the static libs you create is:

create the .lib as describe above.

Don't bother with the .incc file

create an mylib.inc file that looks like this:

use$ "mylib.lib"

declare extern myfunc1(.........)
declare extern myfunc(.........),int


then at the top of the program you want to use the functions in:

include$ "mylib.inc"

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ZeroDog

February 07, 2010, 12:31:23 AM #6 Last Edit: February 07, 2010, 12:33:50 AM by ZeroDog
Thanks  :)

I usually only create single .eba file software, so I didnt even know there was a Statiic Library option in the project options.  I think I've got it now.  

Ive already got a good portion of the command pak finished, but I needed to figure this out so I could add some of my own functions to it, as well as adding some OOP classes.   I might be ready to post a sneak peak of it on the forums shortly.

LarryMc

I think the best way to do it is to create a separate source file for each function.
That's the way EB commands are done(for the most part).

I think it minimizes the size of your program exe by not loading stuff you don't use in your program.

Maybe sapero can tell me if I right for sure.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ZeroDog

I think you're right.  However, they are part of a larger project and are commonly used functions in the command pack, so I think I will keep them all together.  Emergence Basic is great for making nice small binaries, so a couple of extra bytes to the final .exe shouldnt be much of a problem.

Copex

-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/