Weird Programming Problems - errors from good good

Weird Programming Problems - errors from good good

Post by William Harv » Tue, 21 Jan 1997 04:00:00



This weekend I was converting a colorful graphics program written for
OS/2 - Vio full screen graphics to DOS full screen, (My daughters
machine still uses dos/windoze) and ran into an interesting problem
and I'm wondering if anyone else has ever encounter something like
this before.

After replacing the vio calls with dos graphics functions I got an
error message that when something like: found a { but expected a ;.

I looked thought all the code and could find anything wrong so I
started remarking out sections and compiling. When the following code
was remarked out the program compiled without error (of course it did
run.

      if ((y<200) && ((_getpixel(x,y)!=GROUND) || (t<prl)))  {
         _setcolor(0);
                   _setpixel(prt[p][2],prt[p][3]);
         _setcolor(prt[p][5]);
                   _setpixel(x,y);

                   prt[p][2]=x;
                   prt[p][3]=y;
                   prt[p][4]=t;
                }
           else {  prt[p][4]=-2; }

The thing that is strange is that I retyped it in just like it was
(is) and it worked. when I remarked the new section, unremarked the
old, same error. Could there have been a character embedded in the
file which didn't show on the screen causing the problem?

Reminded me of a program I wrote years ago in a computer math class in
college. It was a short, maybe 40 lines, GW-basic program with several
imbedded for-next loops. I kept getting a "next without for" message.
The numbers of for matched the number of next. The proffessor couldn't
figure it out either but when I left the last next out, it worked.
(FWIW my syntax was simple next not next i so that wasn't a problem. I
did try to match them that way also but kept getting the same error).

-------------------------------------------------------
William

http://www.texas.net/~wharvey
team-OS2
------------------------------------------------------

 
 
 

Weird Programming Problems - errors from good good

Post by Kurt A. Spaug » Tue, 21 Jan 1997 04:00:00



> This weekend I was converting a colorful graphics program written for
> OS/2 - Vio full screen graphics to DOS full screen, (My

<snip>
<...interesting problem

Quote:> After replacing the vio calls with dos graphics functions I got an
> error message that when something like: found a { but expected a ;.
> The thing that is strange is that I retyped it in just like it was
> (is) and it worked. when I remarked the new section, unremarked the
> old, same error. Could there have been a character embedded in the
> file which didn't show on the screen causing the problem?

You didn't say what compiler(s) or editors you were
using. I do alot of development on PC's for eventual
use and or storage in a unix environment.  I do know
that tedit,EPM and E don't care if a file has '\n' or
'\r\n' at the end of lines.

Tedit and E will re-write the EOL's as \r\n while EPM leaves
them alone. I think EPM is configurable in this respect.

In porting accross platforms for various compilers, *most* of
the time they don't care, since they internally convert
the CRLF to LF before parsing. but I do recall that I've
encountered difficulties such as yours.  I don't recall
specifics other than it 'goes away' if I run the code through
a DOS<=>UNIX text filter. I [now] routinely 'wash' my source,
whenever I transfer either way.

Don't know where your source has been, so this may be
completely off the mark.  But your symptoms are very similar,
especially the compiles-fine-if-I-retype-it part.

So my shot in the dark:
Is is possible that the broken code has LF's instead
of CRLF's (especially the first line)?
  1) would not be visible on screen
  2) would go away when retyped with a native editor


'Flames are for fire and romance, unless you have neither.'

#include <std_disclaimer.h>

 
 
 

Weird Programming Problems - errors from good good

Post by William Harv » Wed, 22 Jan 1997 04:00:00




>> This weekend I was converting a colorful graphics program written for
>> OS/2 - Vio full screen graphics to DOS full screen, (My
[snip]
>You didn't say what compiler(s) or editors you were
>using. I do alot of development on PC's for eventual
>use and or storage in a unix environment.  I do know
>that tedit,EPM and E don't care if a file has '\n' or
>'\r\n' at the end of lines.

I was using Watcom and EPM for the editor.

Quote:>Tedit and E will re-write the EOL's as \r\n while EPM leaves
>them alone. I think EPM is configurable in this respect.
>In porting accross platforms for various compilers, *most* of
>the time they don't care, since they internally convert
>the CRLF to LF before parsing. but I do recall that I've
>encountered difficulties such as yours.  I don't recall
>specifics other than it 'goes away' if I run the code through
>a DOS<=>UNIX text filter. I [now] routinely 'wash' my source,
>whenever I transfer either way.
>Don't know where your source has been, so this may be
>completely off the mark.  But your symptoms are very similar,
>especially the compiles-fine-if-I-retype-it part.

The source was in a zip file and was a sample program for a small vga
graphics library for OS/2 full screen graphics programming using Vio
calls. I compiled for OS/2 OK just like it was. I only replaced Vio
stuff with DOS graphics counterparts and removed the of necessary
stuff to set up the Vio calls.

Quote:>So my shot in the dark:
>Is is possible that the broken code has LF's instead
>of CRLF's (especially the first line)?
>  1) would not be visible on screen
>  2) would go away when retyped with a native editor

Definitely something funny. This is the 3rd or fourth time I have ran
into this problem. The earlier times were with straight  DOS programs
and I was using M$ C/C++ and their PWB for the editor. Like my father
use to say about fishing, Maybe I just wasn't holding my mouth right.
:)


>'Flames are for fire and romance, unless you have neither.'
>#include <std_disclaimer.h>

-------------------------------------------------------
William

http://www.texas.net/~wharvey
team-OS2
------------------------------------------------------
 
 
 

1. A good newsreader and a good mail program


:>

:>:>I know this question has been asked a million times but, could someone please
:>:>direct me to a good newsreader and or mail program for OS/2. I'm using the
:>
:>Known OS/2 PM Mail and News Programms:
:>PMMAIL, current version 1.1 (My favorite).
:>Post Mail Reader.
  ^^^^^^^^^^^^^^^^

Actually, it is "Post Road Mailer".  :)

Xavier

2. Win2k Not sharing printers with XP

3. ipx routing on a 2514 - oops

4. Good deal on k6 200 and good motherboard?

5. Problems with the Sound Manager

6. Good comm prog. with good VT100 emulation?

7. ORCA/C 1.3

8. Good deal on a k6 200 and good motherboard?

9. FP12: good FPak, good FPak.

10. The OS/2 Feel Good Page (good work!)

11. Good Kaypro needs Good Home II

12. Good Kaypro needs Good Home.