Discussion:
Help Find Error
(too old to reply)
m***@hotmail.com.CUT
2006-10-18 17:58:44 UTC
Permalink
What's wrong with this code??

In PBCC, I get a compile error # 476 here and yet I don't see the
error. (N , ALF and X are declared global variables in PBMAIN)

SUB GetSol()
LOCAL C AS LONG
FOR C = 1 TO X
IF X MOD C <> 0 THEN GOTO 99
IF (C*N+C) MOD ALF <> 0 THEN GOTO 99
CALL UseThis(C)
EXIT SUB
99
NEXT C
END SUB
earthling
2006-10-18 18:45:29 UTC
Permalink
Post by m***@hotmail.com.CUT
What's wrong with this code??
In PBCC, I get a compile error # 476 here and yet I don't see the
error. (N , ALF and X are declared global variables in PBMAIN)
SUB GetSol()
LOCAL C AS LONG
FOR C = 1 TO X
IF X MOD C <> 0 THEN GOTO 99
IF (C*N+C) MOD ALF <> 0 THEN GOTO 99
CALL UseThis(C)
EXIT SUB
99
NEXT C
END SUB
quoted from the pbcc help file error 476:

476 Block/scanned statements not allowed here - Block statements (like
WHILE/WEND, DO/LOOP, and SELECT CASE) are not allowed in single line IF
statements.
Additionally, you may not have a Sub or Function definition nested
within the body of another definition. A missing END SUB or END FUNCTION
can also cause this error.


from that I would look at the call statement or the Usethis(C) routine.
if you rem out that line do you still get the error?
Michael Mattias
2006-10-18 20:36:48 UTC
Permalink
Post by m***@hotmail.com.CUT
What's wrong with this code??
In PBCC, I get a compile error # 476 here and yet I don't see the
error. (N , ALF and X are declared global variables in PBMAIN)
SUB GetSol()
LOCAL C AS LONG
FOR C = 1 TO X
IF X MOD C <> 0 THEN GOTO 99
IF (C*N+C) MOD ALF <> 0 THEN GOTO 99
CALL UseThis(C)
EXIT SUB
99
NEXT C
END SUB
476 Block/scanned statements not allowed here - Block statements (like
WHILE/WEND, DO/LOOP, and SELECT CASE) are not allowed in single line IF
statements.
Additionally, you may not have a Sub or Function definition nested
within the body of another definition. A missing END SUB or END FUNCTION
can also cause this error.
from that I would look at the call statement or the Usethis(C) routine.
if you rem out that line do you still get the error?
If the "here" in " I get a compile error # 476 here" is at the start of the
SUB (the error message gives you a line number and column number!) then your
problem is in the code which precedes the SUB. e.g., no END FUNCTION or
something like that. (just like the quoted error message says).

If "here" is on one of the lines within the sub, show which line and which
column.
Post by m***@hotmail.com.CUT
What's wrong with this code??
When you get this solved, I have an opinion on that, too.

MCM
m***@hotmail.com.CUT
2006-10-19 14:23:49 UTC
Permalink
On Wed, 18 Oct 2006 20:36:48 GMT, "Michael Mattias"
Post by Michael Mattias
Post by earthling
if you rem out that line do you still get the error?
If the "here" in " I get a compile error # 476 here" is at the start of the
SUB (the error message gives you a line number and column number!) then your
problem is in the code which precedes the SUB. e.g., no END FUNCTION or
something like that. (just like the quoted error message says).
The error is # 476 at the start of this sub. But none of the three
reasons listed in the manual as 476 causes is present!
Post by Michael Mattias
If "here" is on one of the lines within the sub, show which line and which
column.
Post by earthling
Post by m***@hotmail.com.CUT
What's wrong with this code??
When you get this solved, I have an opinion on that, too.
MCM
Michael Mattias
2006-10-19 14:59:11 UTC
Permalink
Post by m***@hotmail.com.CUT
The error is # 476 at the start of this sub. But none of the three
reasons listed in the manual as 476 causes is present!
Neither is the error.

This COMPILABLE example is exactly that: Compilable without error using
PB/CC 4.01

Your error is somewhere else. If you need personal attention or assistance,
contact my office for rates and availability.
--
Michael C. Mattias
Tal Systems Inc.
Racine WI
***@talsystems.com

#COMPILE EXE
#DIM ALL
GLOBAL N AS LONG, ALF AS LONG, X AS LONG

FUNCTION PBMAIN () AS LONG

STDOUT "compile test only"

END FUNCTION
' >> In PBCC, I get a compile error # 476 here and yet I don't see the
'>> error. (N , ALF and X are declared global variables in PBMAIN)
SUB GetSol()
LOCAL C AS LONG
FOR C = 1 TO X
IF X MOD C <> 0 THEN GOTO 99
IF (C*N+C) MOD ALF <> 0 THEN GOTO 99
CALL UseThis(C)
EXIT SUB
99
NEXT C
END SUB

' procedure added to make this compilable
FUNCTION UseThis (C AS LONG) AS LONG

FUNCTION = C

END FUNCTION

' //ENDS
m***@hotmail.com.CUT
2006-10-19 14:21:43 UTC
Permalink
Post by earthling
Post by m***@hotmail.com.CUT
What's wrong with this code??
In PBCC, I get a compile error # 476 here and yet I don't see the
error. (N , ALF and X are declared global variables in PBMAIN)
SUB GetSol()
LOCAL C AS LONG
FOR C = 1 TO X
IF X MOD C <> 0 THEN GOTO 99
IF (C*N+C) MOD ALF <> 0 THEN GOTO 99
CALL UseThis(C)
EXIT SUB
99
NEXT C
END SUB
476 Block/scanned statements not allowed here - Block statements (like
WHILE/WEND, DO/LOOP, and SELECT CASE) are not allowed in single line IF
statements.
Additionally, you may not have a Sub or Function definition nested
within the body of another definition. A missing END SUB or END FUNCTION
can also cause this error.
from that I would look at the call statement or the Usethis(C) routine.
if you rem out that line do you still get the error?
None of the three 476 "reasons" is present in this brief code!
There is no
"block statements in a single line if statement" (is that physically
possible ?! a slock of statements in a single line ???)
There is no sub or function definition nested in this definition
There IS an "end of sub statement"
Michael Mattias
2006-10-19 17:59:17 UTC
Permalink
Post by m***@hotmail.com.CUT
There is no
"block statements in a single line if statement" (is that physically
possible ?! a slock of statements in a single line ???)
IF Z THEN _
GOTO Label

This is a single line if statement - using two physical lines via the
underscore continuation character.

IF Z THEN _
FUNCTION Foo
END FUNCTION
GOTO Label

This is a .... 476 error, block/scanned statement not allowed within IF
statement (single line or block)

Academic, anyway. There is no error reported with the posted code (see my
prior note in which I compiled the code without a problem).

He has something wrong somewhere else, somewhere else conveniently not
shown. But just looking at the coding style demonstrated in this brief
snippet, can't say I'm surprised at him getting a 476 error.

MCM

Loading...