Could someone explain to me how to make a link between C++ and SKILL?
I have to develop a program in SKILL. But I do some text treatment in C++. So how I can load my SKILL program, and then lunch my C++ program? I have, in the SKILL program, to have a position with text file from C++.
Ask me if you want more details.
Dave Elder, Tait Communications
It depends upon the integration needed. If your C++program can run as a batch operation with well established I/O with Skill, I would treat it is a seperate binary and have your Skill program launch it via something link the Skill system API. The I/O would typically be based upon files and/or command line arguments. This appoach is typically the fastest to get running and is pretty easy to debug. Also if you have never written Skill before it would be the best approach.
If your C++ code needs to tightly interact with your Skill code then the axlDll approach might be the best. It requires that you turn your C++ code into a dll. See the Allegro Skill reference manual for more info.
In reply to fxffxf:
In reply to Yann00:
To create a dll go to google and type in the following search term "creating a dll", then select "I'm feeling lucky". This assumes you have a copy of Visual Net 2005 from Microsoft, you need this IDE to create a dll that is compatible with Allegro
To bind the dll to Skill read the chapter in the Allegro Skill Reference manual. Search cdsdoc for axlDllOpen and read that entire section.
Looking at your C program it would be easier to have your C program write a file of x/y coordinates that can be easily read by your Skill code. Your Skill code would call your C program via the "system" API and read the file produced by your C program. Unless you need to do this hundreds of times a second, I wouldn't go to all of the extra work to use the axl dll binding method unless you are doing this as a learning experience.
Every way is ok for me if I could run my C program in my SKILL program.
The problem is that all of my C code is in my main. And I don't know how to convert it in a function with (File.h and File.c). I am not really good in fact in programming.
I understood how to create a dll. That was a good tutorial.
But I keep my problem with the transformation from my main to a function (with .h and .c).
When I debug my C++ program, it creates a file called Centre_Cartouche.txt and it works really nice. But I wanna run it during my Skill program running. Because the input of my C++ program is the output of my first function in my SKILL program. My second function in my SKILL program need the output of my C++ program (Centre_Cartouche.txt) to take as an input.
Calling other programs from skill is pretty easy. In your Skill code just do a:
The main issue is dealing where the program exists on disks. You can ask the user or install it in a "well known" location.
What you want to end up with is invoking the system API with the actual location on disk. The alternative method is either modifing the Windows PATH variable to sticking the program into a directory that currently exists in the PATH variable. For example invoking the program via an absolute directory location:
In fact my C++ program has in input the brd.txt ans sym.txt files. This two text files come from the extraction of my fichier.brd in SKILL.
And the C++ program creates in output Centre_Cartouche.txt.
And I need for my next SKILL function to use this Centre_Cartouche.txt to read x and y.
I tried to called my program with system("my_C_program my_arguments") and even if the program is well specified with path it does not work.
Does it turn on yours?
It works for me. I assume you compile/link your program 32bit?
Yes I do.
What did you write in system("??")?
Does it create a file text "Centre_Cartouche.txt"? Because I give you the file Centre_Cartouche.txt just for you to have a look wath it seems like.
) is the two files read by the C++ at the beginning. Centre_Cartouche.txt will be create after treatment on this two files. So Centre_Cartouche.txt is my output.
In reply to ztzg:
So it seems attachments to email replies get eaten by the system.
Trying again, using the web interface; I have also uploaded an unpacked version to:
I tried your example and it seems to be ok.
But there is something wrong when I try to do the same for me... (every time (: )
So I won to create my DLL program. I put files there and it works, it creates my Centre_Cartouche.txt when I Test my DLL.
I tried to import it in my skill program. And strange, ... It doesn't work!
I read the allegro pdf on that but I have some problems to identify my problem.
Did someone already load a dll on his skill program?
Like in C, Skill treats the backslash character (\) as special. If spawning a program via the Skill "system" call. You should try using UNIX style path seperates (/) instead of Windows style. If using backslashes depending upon what you do in creating the string you may need to escape the baclslash (e..g use 2 backslashes to get 1).