www.retrosoftware.co.uk
http://www.retrosoftware.co.uk/forum/

Obtaining parameters passed to a program
http://www.retrosoftware.co.uk/forum/viewtopic.php?f=73&t=145
Page 1 of 1

Author:  FrancisL [ Fri Jul 25, 2008 9:50 am ]
Post subject:  Obtaining parameters passed to a program

Hi guys,

What I am looking for is a way to obtain the parameters passed to a program. E.g. if I do *MYPROG FILENAME how do I get the filename?

Kind regards,

Francis.

Author:  RichTW [ Fri Jul 25, 2008 10:59 am ]
Post subject:  Re: Obtaining parameters passed to a program

OSARGS is your friend (AUG P337)!

Code:
 10 osargs_block=&70
 20 FOR N%=0 TO 2 STEP 2
 30 P%=&900
 40 [OPT N%
 50 .start
 60 LDA #1
 70 LDX #osargs_block
 80 LDY #0
 90 JSR &FFDA
100 LDY #0
110 .printloop
120 LDA (osargs_block),Y
130 CMP #13
140 BEQ finished
150 JSR &FFEE
160 INY
170 BNE loop
180 .finished
190 JMP &FFE3
200 ]:NEXT
210 OSCLI "SAVE CAMELS 900 "+STR$~P%


Code:
>*CAMELS HAVE BEAUTIFUL POUTING LIPS
HAVE BEAUTIFUL POUTING LIPS
>


Hope that helps :)

Author:  FrancisL [ Fri Jul 25, 2008 12:25 pm ]
Post subject:  Re: Obtaining parameters passed to a program

Thanks Rich! I thought that it was something to do with OSARGS, but I couldn't get my head around how to implement it.

It may be that I was just tired when I was originally looking at the docs, but it's so much more simple when you see written down in code. :)

Kind regards,

Francis.

Author:  RichTW [ Fri Jul 25, 2008 12:35 pm ]
Post subject:  Re: Obtaining parameters passed to a program

Nah, I don't really think it's very well explained in the AUG - that's why I had to knock up a test to see if my understanding was right! It doesn't seem to actually mention what is returned, or how it's terminated :?

Author:  FrancisL [ Fri Jul 25, 2008 12:37 pm ]
Post subject:  Re: Obtaining parameters passed to a program

I'm glad it wasn't just me then! :lol:

Kind regards,

Francis.

Author:  FrancisL [ Fri Jul 25, 2008 4:13 pm ]
Post subject:  Re: Obtaining parameters passed to a program

Hi Rich,

There was an error in your code so I have posted a fixed version:

Code:
 10 osargs_block=&70
 20 FOR N%=0 TO 2 STEP 2
 30 P%=&900
 40 [OPT N%
 50 .start
 60 LDA #1
 70 LDX #osargs_block
 80 LDY #0
 90 JSR &FFDA
100 LDY #0
110 .printloop
120 LDA (osargs_block),Y
130 CMP #13
140 BEQ finished
150 JSR &FFEE
160 INY
170 BNE printloop
180 .finished
190 JMP &FFE3
200 ]:NEXT
210 OSCLI "SAVE CAMELS 900 "+STR$~P%

It was just the printloop/loop label that was astray.

Kind regards,

Francis.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/