[comp.sys.amiga] C/AmigaDos Problem

jshortle@jarthur.Claremont.EDU (John Shortle) (04/20/89)

I have written a simple command-line reverse polish notation calculator in C.
If you want to compute (3 - 4 / 7), for example, you type, 'num 3 4 7 / -'.
It works fine unless you end the command with a plus (+) character.  You
must hit return twice, and the program doesn't recognize the plus character
as part of the statement.  I wrote a short program to test this oddity.

test.c (compiled with Manx 3.6a):
---
#include <stdio.h>

main (argc, argv)
int argc;
char *argv[];

{
  int i;
  printf("%d\n", argc);
  for (i = 0; i < argc; i++)
    printf("%s,", argv[i]);
  printf("\n");
}
----

Here are some sample input and output:

>test a -
3
test,a,-,
>test a + (must hit return twice before anything happens)

2
test,a,
>test a +++++ (hit return twice)

3
test,a,++++, (note that one of the plusses is missing)
---
Does anyone know what causes this and/or how to fix it?

Thanks.

disd@hubcap.clemson.edu (Gary Heffelfinger) (04/21/89)

From article <905@jarthur.Claremont.EDU>, by jshortle@jarthur.Claremont.EDU (John Shortle):
> I have written a simple command-line reverse polish notation calculator in C.
> If you want to compute (3 - 4 / 7), for example, you type, 'num 3 4 7 / -'.
> It works fine unless you end the command with a plus (+) character.  You
> must hit return twice, and the program doesn't recognize the plus character
> as part of the statement.  I wrote a short program to test this oddity.
> ---
> Does anyone know what causes this and/or how to fix it?

'+' means "continued on the next line" to DOS.  I don't know how you
could get around it.  You might have to substitute some other character
for the plus sign.






Gary





-- 
Gary R Heffelfinger   -  disd@hubcap.clemson.edu   
"If it should become necessary to fight, could you arrange to find me
     some rocks to throw at them?"   W.T. Riker

new@udel.EDU (Darren New) (04/22/89)

In article <905@jarthur.Claremont.EDU> jshortle@jarthur.UUCP (John Shortle) writes:
>It works fine unless you end the command with a plus (+) character.  You
>must hit return twice, and the program doesn't recognize the plus character
>as part of the statement.  I wrote a short program to test this oddity.

It seems to be part of the CLI parsing mechanism.
For example, try
1> RUN WAIT 10 +
ECHO "HELLO"
 
You get the whole command line, and I think there is
a newline substituted for the plus.  The easiest
fix is to put a space after the plus when you
type the line.  The hardest fix is to patch
the CLI, burn new proms, install them,
and then fix all the third-party execute
scripts that use this feature :-).

cmcmanis%pepper@Sun.COM (Chuck McManis) (04/22/89)

In article <905@jarthur.Claremont.EDU> (John Shortle) writes:
>It works fine unless you end the command with a plus (+) character.

+ on the end of a line is the CLI continuation character. I forget where
this was documented but it was there somewhere. This lets you type longer
lines especially to things like Alink and the like. So it isn't a bug
per say. Since this is the only character that causes this behaviour you
could possible assume that if the command line terminated and you still
had two numbers on the stack that you should add them. (Ok, ok, just kidding
you can put away the tomatoes) :-)



--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.
"A most excellent barbarian ... Genghis Kahn!"

fgd3@jc3b21.UUCP (Fabbian G. Dufoe) (04/22/89)

From article <905@jarthur.Claremont.EDU>, by jshortle@jarthur.Claremont.EDU (John Shortle):
> I have written a simple command-line reverse polish notation calculator in C.
> If you want to compute (3 - 4 / 7), for example, you type, 'num 3 4 7 / -'.
> It works fine unless you end the command with a plus (+) character.  You
> 
> Does anyone know what causes this and/or how to fix it?
> Thanks.

     AmigaDOS uses the plus (+) sign as a command line continuation symbol.
Try typing a space after the plus sign.


--Fabbian Dufoe
  350 Ling-A-Mor Terrace South
  St. Petersburg, Florida  33705
  813-823-2350

UUCP: ...uunet!pdn!jc3b21!fgd3

ins_adjb@jhunix.HCF.JHU.EDU (Daniel Jay Barrett) (04/23/89)

In article <905@jarthur.Claremont.EDU> jshortle@jarthur.UUCP (John Shortle) writes:
>I have written a simple command-line reverse polish notation calculator in C.
>It works fine unless you end the command with a plus (+) character.  You
>must hit return twice, and the program doesn't recognize the plus character
>as part of the statement....

	I'm not sure if this will help, but the '+' character is recognized
by AmigaDOS (at least for the "Run" command) as a command continuation
symbol.  If you end a command line with a plus sign, the CLI expects that
the command isn't finished, and the rest of the command will follow on
the next line.
	I thought this was only for commands that are "Run", though.
-- 
# Dan Barrett	barrett@cs.jhu.edu	(128.220.13.4)	ARPANET             #
#		ins_adjb@jhuvms.bitnet			BITNET              #
#		ins_adjb@jhunix.UUCP			UUCP (unreliable)   #
# Dept. of Computer Science, Johns Hopkins University, Baltimore, MD  21218 #