http://calcg.org/newlogo2.png Not Logged in.
Login | Register

General Discussion Board \ Calculator Programming \ arguments argc/argv of main. howto read on ti?

Click here to log in (you must be logged in to post comments).

AuthorComment
r0f3ll0s
Probe
Posted: 22 Jun 2007
11:06 GMT
Total Posts: 3
i just got my ti-200 yesterday and began a little coding. i'm using tigcc as ide and tiemu for emulation. would be really great if s1 could help me on this.

in c the line:

void _main(int argc, char* argv[])

starts the main-function. if its arguments arent void, you can use argc and argv. if the user opens you program with any parameters, your program is able to use these for further processing. e.g:

...~\pass\pwg 12 14 xyz

is the users input. you'll find pwg,12,14,xyz in argv[], and the number of parameters in argc.
my question: how do i read parameters on a ti? i can't figure out how to put parameters together on ti. i expected sth like:

pwg(12,14,xyz) or pwg(pwg,12,14,xyz)

it wont work. please help. thanks

FW
Barrett
Administrator
avatar
Posted: 22 Jun 2007
12:29 GMT
Total Posts: 1676
Are you programming in BASIC (the on-calc program editor) or TIGCC (computer C editor that compiles programs for use on the calculator)?

---
-Barrett A
r0f3ll0s
Probe
Posted: 23 Jun 2007
02:49 GMT
Total Posts: 3
"i'm using tigcc as ide"

TIGCC in C

i write my program in c. the program expects parameter. compilation is succsesfull. after sending it on the ti i dont know how to input the parameters. so it wont start.
Barrett
Administrator
avatar
Posted: 23 Jun 2007
08:44 GMT
Total Posts: 1676
Oh, now I see. I must have read over that part. Yes, there are ways to read arguments. I believe that that is exactly what the following example program does (from tigcc.ticalc.org):


#define RETURN_VALUE

#define USE_TI89
#define USE_TI92PLUS
#define USE_V200

#define MIN_AMS 101

#include <args.h>
#include <estack.h>

void _main(void)
{
ESI argptr = top_estack;
short a = GetIntArg (argptr);
short b = GetIntArg (argptr);
while (GetArgType (top_estack) != END_TAG) // Clean up arguments
top_estack = next_expression_index (top_estack);
top_estack--;
push_longint (a + b);
}

So, if I'm reading that correctly, a and b are inputted variables.

More information can be found at http://tigcc.ticalc.org or more specifically, here

---
-Barrett A
r0f3ll0s
Probe
Posted: 23 Jun 2007
15:29 GMT
Total Posts: 3
Thanks for your answer.
I found many explanations in the TIGCC documentation. I'm just getting into the stack thing. So far, my program works. Thanks





Portal | My Account | Register | Lost Password or Username | TOS | Disclaimer | Help | Site Search | File Archives Copyright © 2002-2019 CalcG.org