home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / amiga / programm / 19179 < prev    next >
Encoding:
Internet Message Format  |  1993-01-25  |  5.1 KB

  1. Xref: sparky comp.sys.amiga.programmer:19179 comp.sys.amiga.misc:20468
  2. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!bgsuvax!uoft02.utoledo.edu!jupiter!mneylon
  3. Newsgroups: comp.sys.amiga.programmer,comp.sys.amiga.misc
  4. Subject: Re: Strange wierdness in E-language!
  5. Message-ID: <1993Jan25.205721.1282@uoft02.utoledo.edu>
  6. From: mneylon@jupiter.cse.utoledo.edu (Michael Neylon)
  7. Date: 25 Jan 93 20:57:20 EST
  8. References: <1993Jan25.160550.9255@abo.fi>
  9. Nntp-Posting-Host: jupiter.cse.utoledo.edu
  10. Lines: 132
  11.  
  12. MSAASTAMOINE@FINABO.ABO.FI (Mika Saastamoinen Tkkk) writes:
  13. : 1st of all, there's something strange about the IF-THEN-ELSE statement: the
  14. : following statement is supposed to plot a pixel on screen if its coordinates
  15. : (sx,sy) are within given bounds (LFEDGE,RGEDGE,TOEDGE,BOEDGE) (ie. it's a sort
  16. : of primitive clipping thingy):
  17. : IF ((sx>LFEDGE AND sx<RGEDGE) AND (sy>TOEDGE AND sy<BOEDGE)) THEN Plot(sx,sy,2)
  18. : Now then, guess what that did? It plots the pixel no matter what the coordina-
  19. : tes are! And yes, I did check those boundary values, which were defined in 
  20. : CONST statements, and they were correct! The funny thing is that when I conver-
  21. : ted my test program to C, the above if-statement worked correctly, ie. clipped 
  22. : the pixels within the boundaries! Now is this strange or what?
  23.  
  24. I would say that the lack of precedence is screwing this up.  You need more
  25. parens (unfortunately)...try the following...
  26.  
  27. IF ((sx>LFEDGE) AND (sx<RGEDGE) AND (sy>TOEDGE) AND (sy<BOEDGe)) THEN blah...
  28.  
  29. (Note that I have removed a few parens as well ;).
  30.  
  31. : Another thing was this: 
  32. :     This statement works:               IF tz<0 THEN...
  33. :     This statement crashed my machine(!): IF (tz<0 AND tz>-300) THEN...
  34. : The 'tz' was used in a formula like this inside the IF-block: 'sx:=tx/tz' and
  35. : it caused the guru..ehm... software failure #80000005 (I think)... Wierd?
  36. : Again, the latter if-statement worked correctly in the C-version and did NOT
  37. : cause any gurus...
  38.  
  39. Again, lack of precedence screwed this up....The compile sees this as...
  40.  
  41. IF (tz<0 AND tz>-300) THEN ...
  42.     ^  ^  ^   ^   ^
  43.     1  2  3   4   5
  44.  
  45.     1. tz.  No prob.
  46.     2. tz is less than 0, fine no prob.  Let this return 1.
  47.     3. The result of (tz<0) AND the next value (bitwise op)
  48.     4. Now if tz is less than 0, then a bitwise operation will probably 
  49.     crash the computer.
  50.     5. It then takes the result of the bitwise op and tests it against  >-300.
  51.  
  52. A better arrangment will be
  53.  
  54. IF ((tz<0) AND (tz>-300)) THEN ...
  55.  
  56.  
  57. : A third thing concerns the SELECT-ENDSELECT-statement. Consider this:
  58. :     blablabla...
  59. :     ...class:=WaitIMessage(w)...
  60. :     SELECT class
  61. :         CASE IDCMP_RAWKEY
  62. :             code:=GetCode()
  63. :             SELECT code
  64. :                 CASE $45 /* esc */
  65. :                     blabla...
  66. :                 CASE $4d /* cursor down */
  67. :                     blabla...
  68. :                 CASE ...
  69. :                     etc...
  70. :             ENDSELECT
  71. :         CASE IDCMP_INTUITICKS
  72. :             blablabla
  73. :     ENDSELECT
  74. :     blablabla...
  75. : Now, the wierd thing about this is that the program's execution never got
  76. : to the IDCMP_INTUITICKS-part (yes, I did have the IDCMP_INTUITICKS-flag in
  77. : the OpenW()-function's parameters!)!!! Also, it never got to IDCMP_RAWKEY's
  78. : cases beyond the $4d (cursor down)!!! When I changed the order of the rawkey-
  79. : cases, it still didn't get past the first two! Ie. in the above example,
  80. : the program only reacted to the esc- and cursordown-keys (and yes, I did have
  81. : all the rawkey-codes correctly!) The above routine worked only when I dumped
  82. : the SELECTs and used IF-ELSEIF-ENDIF instead:
  83. :     ...
  84. :     IF class=IDCMP_RAWKEY
  85. :         ...
  86. :         IF code=$45 ...
  87. :         ELSEIF code=$4d...
  88. :         ELSEIF code...
  89. :         ENDIF
  90. :     ELSEIF class=IDCMP_INTUITICKS
  91. :     ELSEIF class...
  92. :     ENDIF
  93. :     ...
  94.  
  95. I have a feeling that E does not quite handle nested SELECT-CASE statements
  96. well.  Now it also seems that the above IF structure is very messy, so I
  97. would recommend the following....
  98.  
  99.     SELECT class
  100.         CASE IDCMP_RAWKEY
  101.             HandleRawKey()
  102.         CASE IDCMP_INTUITICKS
  103.             HandleTicks()
  104.     ENDSELECT
  105.  
  106.     ...
  107.  
  108.     PROC HandleRawKey()
  109.         ...
  110.     ENDPROC
  111.  
  112.     and etc..
  113.  
  114. This should inprove your performance, and can make editing much easier (
  115. ie, I can easily rewrite the Rawkey handlers).
  116.  
  117. : E looks like a promising language, but I think I'll still stick with C, since 
  118. : I can at least understand how it works... Also, as many others, I too don't 
  119. : like the one-source-file-philosophy of E, nor do I like the (upper)case-
  120. : sensitivity of it. Other than that, it's quite easy to program the Amiga with 
  121. : E, provided that the above mentioned wierdnesses are inside my head (and my 
  122. : Amiga)... ;)
  123.  
  124.  
  125. As I wrote someone else, the above faults in E are made up for speed in
  126. the compiler.  For someone just begining in Intuition programming, this
  127. is a great language to learn in, and to do a minor adjustment of the 
  128. interface, it only requires a small change in the code, and a few SECONDS
  129. of compile time (on a unaccel. 500!!!)
  130.  
  131.  
  132. -- 
  133. Michael Neylon   aka Masem the Great and Almighty Thermodynamics GOD!
  134.       //         | Senior, Chemical Engineering, Univ. of Toledo
  135.   \\ // Only the |   Summer Intern, NASA Lewis Research Center
  136. \  \X/   AMIGA!  |         mneylon@jupiter.cse.utoledo.edu           /
  137.