Quote:> D3 SCO
> SUBROUTINE WIDGET(A,B,C,D)
> IF 'A'= ALL THEN FOR I = 1 TO DCOUNT(B<1>,CHAR(253))
> B<1,A>=C<1,A>+B<1,A>
> IF B<1,A>='D' THEN
> C<1,A>='P'
> END
> IF 'A'= 'ALL' THEN NEXT I
> RETURN
> wont compile... would anyone familiar with compiler design like to
> explain why?
> I Guess this an example of bad code. Could anyone explain why it's bad?
You don't have clean IF-THEN-END statements first of all. This statement...
IF 'A'= ALL THEN FOR I = 1 TO DCOUNT(B<1>,CHAR(253))
Since the IF-THEN falls on one line it does not need an END statment, but
the FOR-NEXT loop has no NEXT within the IF-THEN
You should probably write it like this...
IF 'A'= ALL THEN
FOR I = 1 TO DCOUNT(B<1>,CHAR(253))
...
...
END
And that brings up the...
'A'= ALL statement. Did you mean A = 'ALL'? As you have it written 'A' is a
literal and ALL is a variable. If you meant A = 'ALL' then you have the
other problem of using A as a VMC.
Then there is the problem of the loop. Your incrementing I each time
through the loop but never using it anywhere. The VMC is constant throught
the loop in your code. You probably meant to write it like this...
SUBROUTINE WIDGET(A,B,C,D)
FOR I = 1 TO DCOUNT(B<1>,CHAR(253))
B<1,I>=C<1,I>+B<1,I>
IF B<1,I>='D' THEN
C<1,I>='P'
END
Next I
RETURN
Why not use A and 'ALL'? Because you never had anything in the code about
what to do when A <> 'ALL' so why include it anyway?
What do we do when A <> 'ALL'? Let's add that to the code later...
Now, what are you trying to do with this...
B<1,A>=C<1,A>+B<1,A>
If the sub-values represented by B<1,A> and C<1,A> are numeric it all works
ok, but your next statement suggests that they could be alpha...
IF B<1,A>='D' THEN ....
So, there is more wrong here than we think.. Can you tell us more?
Mark
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----