|
Sounds like you are unaware of the details of C program startup on
the Amiga. My recollection is that your main routine needs the
following declaration:
main(argc, argv)
int argc; /* Number of arguments. */
char *argv[]; /* Vector of char * s */
If the program is started from the WorkBench, then argc will be 0,
and argv will be set to some info about how it was invoked (don't
remember all the details).
If the program is started from the CLI, then argc will be set to
the number of arguments on the command line, including the name
of the command. Thus to print the file-name argument in your
second question, you could do the following:
printf("file-name: %s\n", argv[1])
Hope that helps,
James M Synge, VMS Performance Analysis, DECnet-VAX
|
| Arguments are passed using argc (count) and argv (values).
Example of usage attached ( from a USENET message ).
Enjoy.
marco
/*
* Handle commandline
*/
main(argc, argv)
int argc;
char *argv;
{
int argno;
int fd, ofd;
char *s, ofn[STRINGSIZ], ifn[STRINGSIZ];
/*
* No instructions:
* print info about use and
* exit with bad return code.
*/
if (argc <= 1)
{
s = "-----------------------------------------------------------------\n";
fprintf(stderr, s);
fprintf(stderr, "CVT version %s %s\n", version, date);
fprintf(stderr, "THIS PROGRAM IS (C)1985 LANDON M. DYER AND MAY BE DISTRIBUTED\n");
fprintf(stderr, "ONLY IF THE FOLLOWING CONDITIONS ARE MET:\n");
fprintf(stderr, "\t1. YOU DO NOT MAKE A PROFIT ON IT.\n");
fprintf(stderr, "\t2. IF YOU HAVE THE SOURCE CODE, YOU GIVE THAT AWAY, TOO.\n");
fprintf(stderr, "\t3. YOU INCLUDE THIS NOTICE IN THE SOURCE AND OBJECT CODE.\n");
fprintf(stderr, s);
fprintf(stderr, "Usage:\n");
fprintf(stderr, "CVT [-d] [-p] inputfile[.LN] [inputfile...]\n");
fprintf(stderr, " ==> file.PRG output files.\n");
exit(1);
}
for (argno = 1; argno < argc; ++argno)
if (*argv[argno] == '-')
for (s = &argv[argno][1]; *s; ++s)
............ and so on !!!
|
|
The argc and argv parameters are not specific to the AMIGA.
They are standard C, therefore are documented in any book about
C. The information passed then the program is run from an ICON
is AMIGA specific.
As for running a program from an ICON, there are things that
must be done to allow a program to be started from an ICON. If
you are using LATTICE C there are 2 different versions of a .obj
file that are linked into your program. Look at the command line
you are using to link program. It should be BLINK L???.obj+progrma.obj
... the first file is the one that controls if a program can be
run from an ICON. I'll look up the exact name and post it.
Steve Peters
|