ProgramParameter and argument passing question:

Everything else that doesn't fall into one of the other PB categories.
Akuma no Houkon
User
User
Posts: 77
Joined: Sun Nov 02, 2003 1:47 pm
Location: Washington
Contact:

ProgramParameter and argument passing question:

Post by Akuma no Houkon »

I have the following C++ declared function:

Usage

Code: Select all

void Init(int *argcp, char **argv);
argcp
A pointer to the program's unmodified argc variable from main.
argv
The program's unmodified argv variable from main.

Now from what I gather, argcp and argv are somehow connected to the command line arguments in languages like C++. I couldnt get any more information than that. I have no idea what to pass to this function or how. Everything I try results in purebasic crashing.

Do any of you know how I would properly call this function via purebasic?
AMD 2600+, nVidia Geforce FX 5200 128 MB DDR, 512 DDR, RedHat 9
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

argc is the number of command line arguments passed - argv are the values themselves.

This is an example that I think might work..

If you execute something on the command line line :

Code: Select all

myprogram -o outfile.txt
then you might call it in PB as

Code: Select all


argc.l = 2

argv.s = "-o outfile.txt"

init(*argc,argv)

I'm pretty sure PB passes strings as pointers already but if not then just pass a pointer to the string instead of the string itself.

Hope that helps!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

argv is a pointer to a pointer, which usually indicates an array of pointers.
My guess is this:

Code: Select all

Dim argv.s(1)

argv(0) = "-o"
argv(1) = "outfile.txt"

argcp = 2

Init(@argcp, @argv())
In PB, a stringarray is an array of stringpointers.

@Karbon:

*argc doesn't give you the address of argc, it creates a new pointer,
that points to NULL. You have to use the '@' here.

Timo
quidquid Latine dictum sit altum videtur
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Ahh, gotcha.. Thanks!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Akuma no Houkon
User
User
Posts: 77
Joined: Sun Nov 02, 2003 1:47 pm
Location: Washington
Contact:

Post by Akuma no Houkon »

Thank you freak. I dont know if the code actually passes the paramaters properly (because I dont use any), but calling the function using the above example works.

The C++ jargon has always been cryptic to me, Thank You.
AMD 2600+, nVidia Geforce FX 5200 128 MB DDR, 512 DDR, RedHat 9
Post Reply