|
Post by bencooper on Apr 20, 2020 0:33:20 GMT -5
I have spent hours trying to debug a program which doesn't produce the expected results printed in a magazine. I don't normally examine the code colouring, but note that the program in one case doesn't recognise a variable E2 (Green) but shows it as a numeral (Red) -see code snippet below.
What is happening - could this be the cause of erroneous results? (E2 becomes a variable if I add a space before it!)
>>>>>>
IF E1>1 THEN GOTO 480
S0=E1
GOTO 520
480
PRINT "Enter Ending Ditch Elevation (Slope if <1.0)";
INPUT E2
500
S0=(E1-E2)/L 'WHY E2 IN RED
PRINT
520
PRINT "Enter Discharge (CFS)";
INPUT Q
>>>>>>>>>>>>
|
|
|
Post by tenochtitlanuk on Apr 20, 2020 4:05:08 GMT -5
Looks like the parsing routine thinks variables with names like E2 are numerics in scientific notation , ie 1 times ten squared.
If so, an LB bug- avoid by using variables with helpful names like 'endElevation'. That has the side effect of making your code flow easier to follow by others- and yourself looking back at it! Another example- 'Q' means nothing to a human reader. 'discharge' does.
PS My first acquaintancee with coding for a real computer was Titan Autocode, which became Fortran. It had HUGELY restricted rules on names of variables and whether they would be integer or float.
|
|
|
Post by Carl Gundel on Apr 20, 2020 7:25:24 GMT -5
There is clearly a bug in the syntax coloring but can you demonstrate any other bug related to variables of the form e[number]??
This example shows the red coloring of e2 but it runs and produces the expected result.
e2 = 4 + 3 print e2 print e1-e2
|
|
|
Post by Rod on Apr 20, 2020 9:29:34 GMT -5
bencooper, click on the ladybug icon to run your program. set a breakpoint by clicking on the left margin of the debug window. Your code will run to the breakpoint. Now step through a line at a time looking at the values held within your variables. The error should become obvious.
As Carl points out it is not the coloring that is giving you the error.
|
|
timur77
Junior Member
Someday I will tell my grandsons that I am older than the Internet. And it will blow their brain.
Posts: 79
|
Post by timur77 on Apr 22, 2020 7:16:22 GMT -5
Several programs had such anomalous errors, as I noticed, usually occurring when using a large number of loop operators, but not always. When viewing through the debugger, I find a line in which it is not what I expected once again to duplicate this line
Example: a=b+c a=b+c
and the operator works as it should. This happens extremely rarely, but it happens. By the way, in version 4.5.1 there are fewer anomalies than in 4.0.3 Maybe the reason is similar.
|
|
timur77
Junior Member
Someday I will tell my grandsons that I am older than the Internet. And it will blow their brain.
Posts: 79
|
Post by timur77 on Apr 22, 2020 7:18:58 GMT -5
can the whole code
|
|