QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: MasterGy on May 27, 2021, 05:22:46 am

Title: in which line am i ?
Post by: MasterGy on May 27, 2021, 05:22:46 am
Hello ! when the program stops with an error message, it also tells you which queue the error is on. If I stop the program, it will exit the program. Is there any .log, large log file where qb records which line the program was on when I stopped it?
This would be very good if it could be read from somewhere, because in an infinite loop it would be easier to find the location of the error.
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 05:56:53 am
it might be possible to hide it in the exe compiler, so that if you stop the program while pressing, for example, the shift or some "secret button", a window would say goodbye to which queue the program was on when you exited.
Title: Re: in which line am i ?
Post by: SMcNeill on May 27, 2021, 07:05:12 am
Write yourself a small routine to error trap your code.

ON ERROR GOTO DebugLine 'can't use GOSUB

ERROR 250 'simulated error code

END
DebugLine:
PRINT _ERRORLINE
RESUME NEXT  ‘Or END, if you want the program to close on error
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 08:34:48 am
the problem is not that simple. for such cases I use it within a cycle
do ..... print # 1, X .... loop

vagy

do .... print timer, X .... loop

from these I see a value within a cycle and also whether it changes (timer)

There is a large program. The game. It runs nicely for minutes and then stops. It always triggers the same thing. But without an error message. So it doesn't break, it stops. exits ctrl + break .... so I think it's running .... . There are a lot of loops working in it and I will check back one by one, but how good it would be if you write ctrl + break somewhere, at which row, at which operation it was aborted. What’s the point of putting in the ERROR 250 if I know where I put it? On this basis I could write ERROR1, ERROR2, ERROR3 after each instruction .....
Title: Re: in which line am i ?
Post by: SpriggsySpriggs on May 27, 2021, 11:33:36 am
I'm not sure you understood Steve's suggestion but another thing you could do is open a console and echo the variable values you want to track. Or, you can write to a text file periodically in your loop and when the program ends you can inspect the last line and see what value the variables were when it failed.
Title: Re: in which line am i ?
Post by: bplus on May 27, 2021, 12:20:38 pm
Yeah I like Spriggsy's suggestion, use console as 2nd window to report program data.

I had same problem in Pool program. It was hanging on breaks because of infinite loops (I thought vector code couldn't handle overlapping balls so I misdiagnosed problem), no errors are thrown so nothing to catch but the program just runs and runs and gets nowhere.

So if you print to console every time you loop some special loop ID you can see where you are getting stuck but this idea will really slow down execution so it is act of extreme desperation ;-))

What I did was printed an line ID before and after points in program and traced it down to where line x wasn't getting to line x + 1 say in top left corner of screen, you will see last line ID point that gets executed. Again slows the program execution way down and to be used only as extreme act of desperation.

Just make 2 points and move them closer and closer together until you isolate the bad section.
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 01:25:54 pm
I managed to find the error.
But from that the question is still given. Because of the example, I made a BAS generation program to understand what I want :)

I'm looking for a mistake just like you. DE! What about this ?
Suppose I change one of the conditions and it does not exit the cycle.
Wouldn’t it be nice to know which line you’re on when we stop?

Code: QB64: [Select]
  1. DO: x0 = x0 + 1
  2.     DO: x1 = x1 + 1
  3.         DO: x2 = x2 + 1
  4.             DO: x3 = x3 + 1
  5.                 DO: x4 = x4 + 1
  6.                     DO: x5 = x5 + 1
  7.                         DO: x6 = x6 + 1
  8.                             DO: x7 = x7 + 1
  9.                                 DO: x8 = x8 + 1
  10.                                     DO: x9 = x9 + 1
  11.                                         DO: x10 = x10 + 1
  12.                                             DO: x11 = x11 + 1
  13.                                                 DO: x12 = x12 + 1
  14.                                                     DO: x13 = x13 + 1
  15.                                                         DO: x14 = x14 + 1
  16.                                                             DO: x15 = x15 + 1
  17.                                                                 DO: x16 = x16 + 1
  18.                                                                     DO: x17 = x17 + 1
  19.                                                                         DO: x18 = x18 + 1
  20.                                                                             DO: x19 = x19 + 1
  21.                                                                                 DO: x20 = x20 + 1
  22.                                                                                     DO: x21 = x21 + 1
  23.                                                                                         DO: x22 = x22 + 1
  24.                                                                                             DO: x23 = x23 + 1
  25.                                                                                                 DO: x24 = x24 + 1
  26.                                                                                                     DO: x25 = x25 + 1
  27.                                                                                                         DO: x26 = x26 + 1
  28.                                                                                                             DO: x27 = x27 + 1
  29.                                                                                                                 DO: x28 = x28 + 1
  30.                                                                                                                     DO: x29 = x29 + 1
  31.                                                                                                                         DO: x30 = x30 + 1
  32.                                                                                                                             DO: x31 = x31 + 1
  33.                                                                                                                                 DO: x32 = x32 + 1
  34.                                                                                                                                     DO: x33 = x33 + 1
  35.                                                                                                                                         DO: x34 = x34 + 1
  36.                                                                                                                                             DO: x35 = x35 + 1
  37.                                                                                                                                                 DO: x36 = x36 + 1
  38.                                                                                                                                                     DO: x37 = x37 + 1
  39.                                                                                                                                                         DO: x38 = x38 + 1
  40.                                                                                                                                                             DO: x39 = x39 + 1
  41.                                                                                                                                                                 DO: x40 = x40 + 1
  42.                                                                                                                                                                     DO: x41 = x41 + 1
  43.                                                                                                                                                                         DO: x42 = x42 + 1
  44.                                                                                                                                                                             DO: x43 = x43 + 1
  45.                                                                                                                                                                                 DO: x44 = x44 + 1
  46.                                                                                                                                                                                     DO: x45 = x45 + 1
  47.                                                                                                                                                                                         DO: x46 = x46 + 1
  48.                                                                                                                                                                                             DO: x47 = x47 + 1
  49.                                                                                                                                                                                                 DO: x48 = x48 + 1
  50.                                                                                                                                                                                                     DO: x49 = x49 + 1
  51.                                                                                                                                                                                                         DO: x50 = x50 + 1
  52.                                                                                                                                                                                                             DO: x51 = x51 + 1
  53.                                                                                                                                                                                                                 DO: x52 = x52 + 1
  54.                                                                                                                                                                                                                     DO: x53 = x53 + 1
  55.                                                                                                                                                                                                                         DO: x54 = x54 + 1
  56.                                                                                                                                                                                                                             DO: x55 = x55 + 1
  57.                                                                                                                                                                                                                                 DO: x56 = x56 + 1
  58.                                                                                                                                                                                                                                     DO: x57 = x57 + 1
  59.                                                                                                                                                                                                                                         DO: x58 = x58 + 1
  60.                                                                                                                                                                                                                                             DO: x59 = x59 + 1
  61.                                                                                                                                                                                                                                                 DO: x60 = x60 + 1
  62.                                                                                                                                                                                                                                                     DO: x61 = x61 + 1
  63.                                                                                                                                                                                                                                                         DO: x62 = x62 + 1
  64.                                                                                                                                                                                                                                                             DO: x63 = x63 + 1
  65.                                                                                                                                                                                                                                                                 DO: x64 = x64 + 1
  66.                                                                                                                                                                                                                                                                     DO: x65 = x65 + 1
  67.                                                                                                                                                                                                                                                                         DO: x66 = x66 + 1
  68.                                                                                                                                                                                                                                                                             DO: x67 = x67 + 1
  69.                                                                                                                                                                                                                                                                                 DO: x68 = x68 + 1
  70.                                                                                                                                                                                                                                                                                     DO: x69 = x69 + 1
  71.                                                                                                                                                                                                                                                                                         DO: x70 = x70 + 1
  72.                                                                                                                                                                                                                                                                                             DO: x71 = x71 + 1
  73.                                                                                                                                                                                                                                                                                                 DO: x72 = x72 + 1
  74.                                                                                                                                                                                                                                                                                                     DO: x73 = x73 + 1
  75.                                                                                                                                                                                                                                                                                                         DO: x74 = x74 + 1
  76.                                                                                                                                                                                                                                                                                                             DO: x75 = x75 + 1
  77.                                                                                                                                                                                                                                                                                                                 DO: x76 = x76 + 1
  78.                                                                                                                                                                                                                                                                                                                     DO: x77 = x77 + 1
  79.                                                                                                                                                                                                                                                                                                                         DO: x78 = x78 + 1
  80.                                                                                                                                                                                                                                                                                                                             DO: x79 = x79 + 1
  81.                                                                                                                                                                                                                                                                                                                                 DO: x80 = x80 + 1
  82.                                                                                                                                                                                                                                                                                                                                     DO: x81 = x81 + 1
  83.                                                                                                                                                                                                                                                                                                                                         DO: x82 = x82 + 1
  84.                                                                                                                                                                                                                                                                                                                                             DO: x83 = x83 + 1
  85.                                                                                                                                                                                                                                                                                                                                                 DO: x84 = x84 + 1
  86.                                                                                                                                                                                                                                                                                                                                                     DO: x85 = x85 + 1
  87.                                                                                                                                                                                                                                                                                                                                                         DO: x86 = x86 + 1
  88.                                                                                                                                                                                                                                                                                                                                                             DO: x87 = x87 + 1
  89.                                                                                                                                                                                                                                                                                                                                                                 DO: x88 = x88 + 1
  90.                                                                                                                                                                                                                                                                                                                                                                     DO: x89 = x89 + 1
  91.                                                                                                                                                                                                                                                                                                                                                                         DO: x90 = x90 + 1
  92.                                                                                                                                                                                                                                                                                                                                                                             DO: x91 = x91 + 1
  93.                                                                                                                                                                                                                                                                                                                                                                                 DO: x92 = x92 + 1
  94.                                                                                                                                                                                                                                                                                                                                                                                     DO: x93 = x93 + 1
  95.                                                                                                                                                                                                                                                                                                                                                                                         DO: x94 = x94 + 1
  96.                                                                                                                                                                                                                                                                                                                                                                                             DO: x95 = x95 + 1
  97.                                                                                                                                                                                                                                                                                                                                                                                                 DO: x96 = x96 + 1
  98.                                                                                                                                                                                                                                                                                                                                                                                                     DO: x97 = x97 + 1
  99.                                                                                                                                                                                                                                                                                                                                                                                                         DO: x98 = x98 + 1
  100.                                                                                                                                                                                                                                                                                                                                                                                                             DO: x99 = x99 + 1
  101.                                                                                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x99 < 10
  102.                                                                                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x98 < 10
  103.                                                                                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x97 < 10
  104.                                                                                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x96 < 10
  105.                                                                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x95 < 10
  106.                                                                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x94 < 10
  107.                                                                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x93 < 10
  108.                                                                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x92 < 10
  109.                                                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x91 < 10
  110.                                                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x90 < 10
  111.                                                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x89 < 10
  112.                                                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x88 < 10
  113.                                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x87 < 10
  114.                                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x86 < 10
  115.                                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x85 < 10
  116.                                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x84 < 10
  117.                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x83 < 10
  118.                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x82 < 10
  119.                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x81 < 10
  120.                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x80 < 10
  121.                                                                                                                                                                                                                                                                                                                             LOOP WHILE x79 < 10
  122.                                                                                                                                                                                                                                                                                                                         LOOP WHILE x78 < 10
  123.                                                                                                                                                                                                                                                                                                                     LOOP WHILE x77 < 10
  124.                                                                                                                                                                                                                                                                                                                 LOOP WHILE x76 < 10
  125.                                                                                                                                                                                                                                                                                                             LOOP WHILE x75 < 10
  126.                                                                                                                                                                                                                                                                                                         LOOP WHILE x74 < 10
  127.                                                                                                                                                                                                                                                                                                     LOOP WHILE x73 < 10
  128.                                                                                                                                                                                                                                                                                                 LOOP WHILE x72 < 10
  129.                                                                                                                                                                                                                                                                                             LOOP WHILE x71 < 10
  130.                                                                                                                                                                                                                                                                                         LOOP WHILE x70 < 10
  131.                                                                                                                                                                                                                                                                                     LOOP WHILE x69 < 10
  132.                                                                                                                                                                                                                                                                                 LOOP WHILE x68 < 10
  133.                                                                                                                                                                                                                                                                             LOOP WHILE x67 < 10
  134.                                                                                                                                                                                                                                                                         LOOP WHILE x66 < 10
  135.                                                                                                                                                                                                                                                                     LOOP WHILE x65 < 10
  136.                                                                                                                                                                                                                                                                 LOOP WHILE x64 < 10
  137.                                                                                                                                                                                                                                                             LOOP WHILE x63 < 10
  138.                                                                                                                                                                                                                                                         LOOP WHILE x62 < 10
  139.                                                                                                                                                                                                                                                     LOOP WHILE x61 < 10
  140.                                                                                                                                                                                                                                                 LOOP WHILE x60 < 10
  141.                                                                                                                                                                                                                                             LOOP WHILE x59 < 10
  142.                                                                                                                                                                                                                                         LOOP WHILE x58 < 10
  143.                                                                                                                                                                                                                                     LOOP WHILE x57 < 10
  144.                                                                                                                                                                                                                                 LOOP WHILE x56 < 10
  145.                                                                                                                                                                                                                             LOOP WHILE x55 < 10
  146.                                                                                                                                                                                                                         LOOP WHILE x54 < 10
  147.                                                                                                                                                                                                                     LOOP WHILE x53 < 10
  148.                                                                                                                                                                                                                 LOOP WHILE x52 < 10
  149.                                                                                                                                                                                                             LOOP WHILE x51 < 10
  150.                                                                                                                                                                                                         LOOP WHILE x50 < 10
  151.                                                                                                                                                                                                     LOOP WHILE x49 < 10
  152.                                                                                                                                                                                                 LOOP WHILE x48 < 10
  153.                                                                                                                                                                                             LOOP WHILE x47 < 10
  154.                                                                                                                                                                                         LOOP WHILE x46 < 10
  155.                                                                                                                                                                                     LOOP WHILE x45 < 10
  156.                                                                                                                                                                                 LOOP WHILE x44 < 10
  157.                                                                                                                                                                             LOOP WHILE x43 < 10
  158.                                                                                                                                                                         LOOP WHILE x42 < 10
  159.                                                                                                                                                                     LOOP WHILE x41 < 10
  160.                                                                                                                                                                 LOOP WHILE x40 < 10
  161.                                                                                                                                                             LOOP WHILE x39 < 10
  162.                                                                                                                                                         LOOP WHILE x38 < 10
  163.                                                                                                                                                     LOOP WHILE x37 < 10
  164.                                                                                                                                                 LOOP WHILE x36 < 10
  165.                                                                                                                                             LOOP WHILE x35 < 10
  166.                                                                                                                                         LOOP WHILE x34 < 10
  167.                                                                                                                                     LOOP WHILE x33 < 10
  168.                                                                                                                                 LOOP WHILE x32 < 10
  169.                                                                                                                             LOOP WHILE x31 < 10
  170.                                                                                                                         LOOP WHILE x30 < 10
  171.                                                                                                                     LOOP WHILE x29 < 10
  172.                                                                                                                 LOOP WHILE x28 < 10
  173.                                                                                                             LOOP WHILE x27 < 10
  174.                                                                                                         LOOP WHILE x26 < 10
  175.                                                                                                     LOOP WHILE x25 < 10
  176.                                                                                                 LOOP WHILE x24 < 10
  177.                                                                                             LOOP WHILE x23 < 10
  178.                                                                                         LOOP WHILE x22 < 10
  179.                                                                                     LOOP WHILE x21 < 10
  180.                                                                                 LOOP WHILE x20 < 10
  181.                                                                             LOOP WHILE x19 < 10
  182.                                                                         LOOP WHILE x18 < 10
  183.                                                                     LOOP WHILE x17 < 10
  184.                                                                 LOOP WHILE x16 < 10
  185.                                                             LOOP WHILE x15 < 10
  186.                                                         LOOP WHILE x14 < 10
  187.                                                     LOOP WHILE x13 < 10
  188.                                                 LOOP WHILE x12 < 10
  189.                                             LOOP WHILE x11 < 10
  190.                                         LOOP WHILE x10 < 10
  191.                                     LOOP WHILE x9 < 10
  192.                                 LOOP WHILE x8 < 10
  193.                             LOOP WHILE x7 < 10
  194.                         LOOP WHILE x6 < 10
  195.                     LOOP WHILE x5 < 10
  196.                 LOOP WHILE x4 < 10
  197.             LOOP WHILE x3 < 10
  198.         LOOP WHILE x2 < 10
  199.     LOOP WHILE x1 < 10
  200. LOOP WHILE x0 < 10
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 01:28:54 pm
don't avoid the question! if I stop the program and get which queue you went to, it’s a huge help in many cases!
Title: Re: in which line am i ?
Post by: SpriggsySpriggs on May 27, 2021, 01:34:20 pm
Good grief that looks like way too much
Title: Re: in which line am i ?
Post by: SMcNeill on May 27, 2021, 01:37:25 pm
Here, as I was saying above -- just write your own error handler:

Code: QB64: [Select]
  1. ON ERROR GOTO DebugLine 'can't use GOSUB
  2.  
  3.  
  4. DO: x0 = x0 + 1
  5.     DO: x1 = x1 + 1
  6.         DO: x2 = x2 + 1
  7.             DO: x3 = x3 + 1
  8.                 DO: x4 = x4 + 1
  9.                     DO: x5 = x5 + 1
  10.                         DO: x6 = x6 + 1
  11.                             DO: x7 = x7 + 1
  12.                                 DO: x8 = x8 + 1
  13.                                     DO: x9 = x9 + 1
  14.                                         DO: x10 = x10 + 1
  15.                                             DO: x11 = x11 + 1
  16.                                                 DO: x12 = x12 + 1
  17.                                                     DO: x13 = x13 + 1
  18.                                                         DO: x14 = x14 + 1
  19.                                                             DO: x15 = x15 + 1
  20.                                                                 DO: x16 = x16 + 1
  21.                                                                     DO: x17 = x17 + 1
  22.                                                                         DO: x18 = x18 + 1
  23.                                                                             DO: x19 = x19 + 1
  24.                                                                                 DO: x20 = x20 + 1
  25.                                                                                     DO: x21 = x21 + 1
  26.                                                                                         DO: x22 = x22 + 1
  27.                                                                                             DO: x23 = x23 + 1
  28.                                                                                                 DO: x24 = x24 + 1
  29.                                                                                                     DO: x25 = x25 + 1
  30.                                                                                                         DO: x26 = x26 + 1
  31.                                                                                                             DO: x27 = x27 + 1
  32.                                                                                                                 DO: x28 = x28 + 1
  33.                                                                                                                     DO: x29 = x29 + 1
  34.                                                                                                                         DO: x30 = x30 + 1
  35.                                                                                                                             DO: x31 = x31 + 1
  36.                                                                                                                                 DO: x32 = x32 + 1
  37.                                                                                                                                     DO: x33 = x33 + 1
  38.                                                                                                                                         DO: x34 = x34 + 1
  39.                                                                                                                                             DO: x35 = x35 + 1
  40.                                                                                                                                                 DO: x36 = x36 + 1
  41.                                                                                                                                                     DO: x37 = x37 + 1
  42.                                                                                                                                                         DO: x38 = x38 + 1
  43.                                                                                                                                                             DO: x39 = x39 + 1
  44.                                                                                                                                                                 DO: x40 = x40 + 1
  45.                                                                                                                                                                     DO: x41 = x41 + 1
  46.                                                                                                                                                                         DO: x42 = x42 + 1
  47.                                                                                                                                                                             DO: x43 = x43 + 1
  48.                                                                                                                                                                                 DO: x44 = x44 + 1
  49.                                                                                                                                                                                     DO: x45 = x45 + 1
  50.                                                                                                                                                                                         DO: x46 = x46 + 1
  51.                                                                                                                                                                                             DO: x47 = x47 + 1
  52.                                                                                                                                                                                                 DO: x48 = x48 + 1
  53.                                                                                                                                                                                                     DO: x49 = x49 + 1
  54.                                                                                                                                                                                                         DO: x50 = x50 + 1
  55.                                                                                                                                                                                                             DO: x51 = x51 + 1
  56.                                                                                                                                                                                                                 DO: x52 = x52 + 1
  57.                                                                                                                                                                                                                     DO: x53 = x53 + 1
  58.                                                                                                                                                                                                                         DO: x54 = x54 + 1
  59.                                                                                                                                                                                                                             DO: x55 = x55 + 1
  60.                                                                                                                                                                                                                                 DO: x56 = x56 + 1
  61.                                                                                                                                                                                                                                     DO: x57 = x57 + 1
  62.                                                                                                                                                                                                                                         DO: x58 = x58 + 1
  63.                                                                                                                                                                                                                                             DO: x59 = x59 + 1
  64.                                                                                                                                                                                                                                                 DO: x60 = x60 + 1
  65.                                                                                                                                                                                                                                                     DO: x61 = x61 + 1
  66.                                                                                                                                                                                                                                                         DO: x62 = x62 + 1
  67.                                                                                                                                                                                                                                                             DO: x63 = x63 + 1
  68.                                                                                                                                                                                                                                                                 DO: x64 = x64 + 1
  69.                                                                                                                                                                                                                                                                     DO: x65 = x65 + 1
  70.                                                                                                                                                                                                                                                                         DO: x66 = x66 + 1
  71.                                                                                                                                                                                                                                                                             DO: x67 = x67 + 1
  72.                                                                                                                                                                                                                                                                                 DO: x68 = x68 + 1
  73.                                                                                                                                                                                                                                                                                     DO: x69 = x69 + 1
  74.                                                                                                                                                                                                                                                                                         DO: x70 = x70 + 1
  75.                                                                                                                                                                                                                                                                                             DO: x71 = x71 + 1
  76.                                                                                                                                                                                                                                                                                                 DO: x72 = x72 + 1
  77.                                                                                                                                                                                                                                                                                                     DO: x73 = x73 + 1
  78.                                                                                                                                                                                                                                                                                                         DO: x74 = x74 + 1
  79.                                                                                                                                                                                                                                                                                                             DO: x75 = x75 + 1
  80.                                                                                                                                                                                                                                                                                                                 DO: x76 = x76 + 1
  81.                                                                                                                                                                                                                                                                                                                     DO: x77 = x77 + 1
  82.                                                                                                                                                                                                                                                                                                                         DO: x78 = x78 + 1
  83.                                                                                                                                                                                                                                                                                                                             DO: x79 = x79 + 1
  84.                                                                                                                                                                                                                                                                                                                                 DO: x80 = x80 + 1
  85.                                                                                                                                                                                                                                                                                                                                     DO: x81 = x81 + 1
  86.                                                                                                                                                                                                                                                                                                                                         DO: x82 = x82 + 1
  87.                                                                                                                                                                                                                                                                                                                                             DO: x83 = x83 + 1
  88.                                                                                                                                                                                                                                                                                                                                                 DO: x84 = x84 + 1
  89.                                                                                                                                                                                                                                                                                                                                                     DO: x85 = x85 + 1
  90.                                                                                                                                                                                                                                                                                                                                                         DO: x86 = x86 + 1
  91.                                                                                                                                                                                                                                                                                                                                                             DO: x87 = x87 + 1
  92.                                                                                                                                                                                                                                                                                                                                                                 DO: x88 = x88 + 1
  93.                                                                                                                                                                                                                                                                                                                                                                     DO: x89 = x89 + 1
  94.                                                                                                                                                                                                                                                                                                                                                                         DO: x90 = x90 + 1
  95.                                                                                                                                                                                                                                                                                                                                                                             DO: x91 = x91 + 1
  96.                                                                                                                                                                                                                                                                                                                                                                                 DO: x92 = x92 + 1
  97.                                                                                                                                                                                                                                                                                                                                                                                     DO: x93 = x93 + 1
  98.                                                                                                                                                                                                                                                                                                                                                                                         DO: x94 = x94 + 1
  99.                                                                                                                                                                                                                                                                                                                                                                                             DO: x95 = x95 + 1
  100.                                                                                                                                                                                                                                                                                                                                                                                                 DO: x96 = x96 + 1
  101.                                                                                                                                                                                                                                                                                                                                                                                                     DO: x97 = x97 + 1
  102.                                                                                                                                                                                                                                                                                                                                                                                                         DO: x98 = x98 + 1
  103.                                                                                                                                                                                                                                                                                                                                                                                                             DO: x99 = x99 + 1
  104.                                                                                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x99 < 10
  105.                                                                                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x98 < 10
  106.                                                                                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x97 < 10
  107.                                                                                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x96 < 10
  108.                                                                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x95 < 10
  109.                                                                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x94 < 10
  110.                                                                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x93 < 10
  111.                                                                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x92 < 10
  112.                                                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x91 < 10
  113.                                                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x90 < 10
  114.                                                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x89 < 10
  115.                                                                                                                                                                                                                                                                                                                                                                     ERROR 5 'genereate an error on this  line on purpose
  116.                                                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x88 < 10
  117.                                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x87 < 10
  118.                                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x86 < 10
  119.                                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x85 < 10
  120.                                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x84 < 10
  121.                                                                                                                                                                                                                                                                                                                                             LOOP WHILE x83 < 10
  122.                                                                                                                                                                                                                                                                                                                                         LOOP WHILE x82 < 10
  123.                                                                                                                                                                                                                                                                                                                                     LOOP WHILE x81 < 10
  124.                                                                                                                                                                                                                                                                                                                                 LOOP WHILE x80 < 10
  125.                                                                                                                                                                                                                                                                                                                             LOOP WHILE x79 < 10
  126.                                                                                                                                                                                                                                                                                                                         LOOP WHILE x78 < 10
  127.                                                                                                                                                                                                                                                                                                                     LOOP WHILE x77 < 10
  128.                                                                                                                                                                                                                                                                                                                 LOOP WHILE x76 < 10
  129.                                                                                                                                                                                                                                                                                                             LOOP WHILE x75 < 10
  130.                                                                                                                                                                                                                                                                                                         LOOP WHILE x74 < 10
  131.                                                                                                                                                                                                                                                                                                     LOOP WHILE x73 < 10
  132.                                                                                                                                                                                                                                                                                                 LOOP WHILE x72 < 10
  133.                                                                                                                                                                                                                                                                                             LOOP WHILE x71 < 10
  134.                                                                                                                                                                                                                                                                                         LOOP WHILE x70 < 10
  135.                                                                                                                                                                                                                                                                                     LOOP WHILE x69 < 10
  136.                                                                                                                                                                                                                                                                                 LOOP WHILE x68 < 10
  137.                                                                                                                                                                                                                                                                             LOOP WHILE x67 < 10
  138.                                                                                                                                                                                                                                                                         LOOP WHILE x66 < 10
  139.                                                                                                                                                                                                                                                                     LOOP WHILE x65 < 10
  140.                                                                                                                                                                                                                                                                 LOOP WHILE x64 < 10
  141.                                                                                                                                                                                                                                                             LOOP WHILE x63 < 10
  142.                                                                                                                                                                                                                                                         LOOP WHILE x62 < 10
  143.                                                                                                                                                                                                                                                     LOOP WHILE x61 < 10
  144.                                                                                                                                                                                                                                                 LOOP WHILE x60 < 10
  145.                                                                                                                                                                                                                                             LOOP WHILE x59 < 10
  146.                                                                                                                                                                                                                                         LOOP WHILE x58 < 10
  147.                                                                                                                                                                                                                                     LOOP WHILE x57 < 10
  148.                                                                                                                                                                                                                                 LOOP WHILE x56 < 10
  149.                                                                                                                                                                                                                             LOOP WHILE x55 < 10
  150.                                                                                                                                                                                                                         LOOP WHILE x54 < 10
  151.                                                                                                                                                                                                                     LOOP WHILE x53 < 10
  152.                                                                                                                                                                                                                 LOOP WHILE x52 < 10
  153.                                                                                                                                                                                                             LOOP WHILE x51 < 10
  154.                                                                                                                                                                                                         LOOP WHILE x50 < 10
  155.                                                                                                                                                                                                     LOOP WHILE x49 < 10
  156.                                                                                                                                                                                                 LOOP WHILE x48 < 10
  157.                                                                                                                                                                                             LOOP WHILE x47 < 10
  158.                                                                                                                                                                                         LOOP WHILE x46 < 10
  159.                                                                                                                                                                                     LOOP WHILE x45 < 10
  160.                                                                                                                                                                                 LOOP WHILE x44 < 10
  161.                                                                                                                                                                             LOOP WHILE x43 < 10
  162.                                                                                                                                                                         LOOP WHILE x42 < 10
  163.                                                                                                                                                                     LOOP WHILE x41 < 10
  164.                                                                                                                                                                 LOOP WHILE x40 < 10
  165.                                                                                                                                                             LOOP WHILE x39 < 10
  166.                                                                                                                                                         LOOP WHILE x38 < 10
  167.                                                                                                                                                     LOOP WHILE x37 < 10
  168.                                                                                                                                                 LOOP WHILE x36 < 10
  169.                                                                                                                                             LOOP WHILE x35 < 10
  170.                                                                                                                                         LOOP WHILE x34 < 10
  171.                                                                                                                                     LOOP WHILE x33 < 10
  172.                                                                                                                                 LOOP WHILE x32 < 10
  173.                                                                                                                             LOOP WHILE x31 < 10
  174.                                                                                                                         LOOP WHILE x30 < 10
  175.                                                                                                                     LOOP WHILE x29 < 10
  176.                                                                                                                 LOOP WHILE x28 < 10
  177.                                                                                                             LOOP WHILE x27 < 10
  178.                                                                                                         LOOP WHILE x26 < 10
  179.                                                                                                     LOOP WHILE x25 < 10
  180.                                                                                                 LOOP WHILE x24 < 10
  181.                                                                                             LOOP WHILE x23 < 10
  182.                                                                                         LOOP WHILE x22 < 10
  183.                                                                                     LOOP WHILE x21 < 10
  184.                                                                                 LOOP WHILE x20 < 10
  185.                                                                             LOOP WHILE x19 < 10
  186.                                                                         LOOP WHILE x18 < 10
  187.                                                                     LOOP WHILE x17 < 10
  188.                                                                 LOOP WHILE x16 < 10
  189.                                                             LOOP WHILE x15 < 10
  190.                                                         LOOP WHILE x14 < 10
  191.                                                     LOOP WHILE x13 < 10
  192.                                                 LOOP WHILE x12 < 10
  193.                                             LOOP WHILE x11 < 10
  194.                                         LOOP WHILE x10 < 10
  195.                                     LOOP WHILE x9 < 10
  196.                                 LOOP WHILE x8 < 10
  197.                             LOOP WHILE x7 < 10
  198.                         LOOP WHILE x6 < 10
  199.                     LOOP WHILE x5 < 10
  200.                 LOOP WHILE x4 < 10
  201.             LOOP WHILE x3 < 10
  202.         LOOP WHILE x2 < 10
  203.     LOOP WHILE x1 < 10
  204. LOOP WHILE x0 < 10
  205.  
  206.  
  207. DebugLine:
  208. PRINT "Your program has generated an error -- ERROR #"; ERR; "on line #"; _ERRORLINE
  209. PRINT "Would you like to save this information to disk?"
  210.     a$ = UCASE$(INKEY$)
  211.     _LIMIT 10
  212. LOOP UNTIL a$ = "Y" OR a$ = "N"
  213. IF a$ = "Y" THEN
  214.     OPEN "temp.txt" FOR OUTPUT AS #1
  215.     PRINT #1, "Your program has generated an error -- ERROR #"; ERR; "on line #"; _ERRORLINE
  216.  

I used your example and tossed a simulated error in there at some random point, and this seems to do the job for me on finding it easily enough.  Are you certain something like this won't work for your needs?
Title: Re: in which line am i ?
Post by: bplus on May 27, 2021, 01:48:16 pm
But @SMcNeill  you need an error thrown! In an infinite loop no errors get thrown. Am I missing something?

I say either:
1: print out all x(i) (and why not use an array MasterGy?) in console window and see which one isn't going anywhere

or
2: print loop id number before and after the loop(s) and narrow down the problem loop.

print (to console?) enter loop IdX
do(s)
  print enter loop IdY
  do(s)

  loops
  print exit  loop IdY
loop(s)
print exit loop IdX

for nested loops start in deepest nest and work your way out until you don't get an exit message.
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 01:49:19 pm
SMcNeil, and if the infinite cycle does not occur at 89? we are there. then in the worst case I have to place "error 5" in 100 places and try again? Instead of "error 5" we can also do "print" HERE I AM ".... this does not solve the infinite loop error finding.
Title: Re: in which line am i ?
Post by: SMcNeill on May 27, 2021, 01:50:02 pm
If you're talking about storing the line number for when you decide to manually close a program, you'd want to use _EXIT and ON TIMER to create a custom exit loop, along with a variable to store the line numbers you want to track.

Code: QB64: [Select]
  1.  
  2. t1 = FREETIMER
  3. ON TIMER(t1, 0.1) CheckExit
  4. TIMER(t1) ON
  5.  
  6. ln = 1: DO
  7.     ln = 2: DO
  8.         ln = 3: DO
  9.             ln = 4: DO
  10.             ln = 5: LOOP
  11.         ln = 6: LOOP
  12.     ln = 7: LOOP
  13. ln = 8: LOOP
  14.  
  15. SUB CheckExit
  16.     IF _EXIT THEN
  17.         PRINT "You manually exited the program on line #"; ln
  18.         SLEEP
  19.         END
  20.     END IF
  21.  

All endless loops.  This would normally lock a program up forever more, but you can use the nice big red X in the top right corner to exit and end the program at any time -- and when you do so, it'll tell you the line that it was on when you exited the program..

Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 01:52:54 pm
yes Bplus, do you understand what I mean!
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:01:46 pm
Wow ! i like this _EXIT command, i didn't know it before! De! you still avoided the question! You made 5 cycles and identified each one. I intentionally showed 100 cycles. then I put an ID in front of all a hundred? If I did, it would be enough to print the ID with an "on key".
Title: Re: in which line am i ?
Post by: bplus on May 27, 2021, 02:03:29 pm
yes Bplus, do you understand what I mean!

I think I do, but Steve's last looks better than my ideas so far, specially for the monster you show LOL!
Title: Re: in which line am i ?
Post by: bplus on May 27, 2021, 02:07:20 pm
Wow ! i like this _EXIT command, i didn't know it before! De! you still avoided the question! You made 5 cycles and identified each one. I intentionally showed 100 cycles. then I put an ID in front of all a hundred? If I did, it would be enough to print the ID with an "on key".

Even better!
Title: Re: in which line am i ?
Post by: SMcNeill on May 27, 2021, 02:07:55 pm
Wow ! i like this _EXIT command, i didn't know it before! De! you still avoided the question! You made 5 cycles and identified each one. I intentionally showed 100 cycles. then I put an ID in front of all a hundred? If I did, it would be enough to print the ID with an "on key".

As far as I know, there's no _LINENUMBER command built into QB64, so there's no way to get that value back natively without generating your own ID.  If you're going with 100 loops, and glitch out in them, then you might want to try Felippe's debugger (which basically adds the labels before compiling your code automatically), or else just add them yourself. 
Title: Re: in which line am i ?
Post by: SpriggsySpriggs on May 27, 2021, 02:08:18 pm
You keep saying he's avoiding the question but I don't see that being the case. Perhaps you aren't explaining your problem clearly? I would think you are saying that your program is crashing to desktop rather than failing with a message box alert, correct?
Title: Re: in which line am i ?
Post by: SpriggsySpriggs on May 27, 2021, 02:09:11 pm
As far as I know, there's no _LINENUMBER command built into QB64, so there's no way to get that value back natively without generating your own ID.  If you're going with 100 loops, and glitch out in them, then you might want to try Felippe's debugger (which basically adds the labels before compiling your code automatically), or else just add them yourself.

You can use a preprocessor macro in a header to generate a static count. Each time the function is called it is increased by 1. That could be helpful, perhaps. Perhaps not.
Title: Re: in which line am i ?
Post by: bplus on May 27, 2021, 02:14:16 pm
Aha the Interpreter advantage, press a key and piece of cake to tell what line number you're on and what all the variables are looking like at that moment! And stepping through code, and setting break points... all that good ole stuff!
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:15:37 pm
Thank you for your answers. the torment remains. Due to the lack of a simple thing about which queue to stop running when we exit.
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:19:23 pm
yes Bplus, it helped a lot, for example such a problem was solved in an instant. I remember under DOS :) Unfortunately, it takes 1 day for a 160kbyte program to see where this kind of error is.
Title: Re: in which line am i ?
Post by: SMcNeill on May 27, 2021, 02:25:10 pm
I don’t think you’ll ever find simple answers with 100 loops stacked.

Do
   Do
       Do
           Do
                Do....


Now, let’s say the 2nd loop is the endless loop...  if we manually exit, or hit a key at any time (such as ON KEY), WHY would we do it inside loop 2?  Why couldn’t the program be in loop 3, 4, 5+ when we exit?  Those loops all run fine; it’s not until we get to loop 2 that we endlessly repeat.   Just having a line number by itself doesn’t help much, or at least, I don’t see how it could.
Title: Re: in which line am i ?
Post by: SMcNeill on May 27, 2021, 02:26:25 pm
Aha the Interpreter advantage, press a key and piece of cake to tell what line number you're on and what all the variables are looking like at that moment! And stepping through code, and setting break points... all that good ole stuff!

https://www.qb64.org/forum/index.php?topic=458.0 — That’s the closest to all that ole stuff that you’re going to come.
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:29:42 pm
Bplus, anyway i am very happy with the QB64! if it weren’t for it, I wouldn’t be able to implement my ideas so quickly, efficiently. In the old days, unfortunately, because of speed, I was forced to give up a lot of things. This shortcoming is a trifle. In the next version, I will suggest that if ctrl + break exits, if you also press SHIFT, for example, a window will say goodbye, which will print out which queue the processing took. I think that would solve the infinite-cycle problem.
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:30:15 pm
SMcNeil, suppose I give you a program. huge size. be 10Mbyte and one day it would be read. I secretly place a "DO: LOOP" in it. You are sure that the program will not run due to an endless cycle. My suggestion would solve this problem in an instant. Otherwise, it may take 1 week to find the error.
Title: Re: in which line am i ?
Post by: bplus on May 27, 2021, 02:30:54 pm
@MasterGy couldn't you check your loops from the inside out with that key press thing (as opposed to exit) you could see if entering and exiting innermost, then check next innermost... keep going until you find the bad one?

I am talking about a method electricians use to track down a bad component or circuit.

The inner most loop is what has to pass to get to next item in 2nd inner most loop...
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:34:06 pm
Thanks, SMcNeill, I'm going to try this!
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:37:03 pm
Thanks Bplus for the idea! I already found the error. It took a few hours. But if I know which line you’re stuck with, I’ll win a couple of hours. So the problem remains. It could help anyone at any time if we at least knew where the program was going. All this without loading the source code just for debugging.
Title: Re: in which line am i ?
Post by: Richard on May 27, 2021, 02:38:49 pm
If I understand correctly...

The problem relates to where you were in a program  when you prematurely terminate a running program (because of say an infinite loop).

Things can get "messy" because QB64 is a compiled based environment. In the old days (some 30 years ago) this type of problem was addressed by using an interpreter based BASIC (eg MS PDS 7.1 which was an upgrade to QB45). I do not know of QB45 (never used it) but with PDS 7.1 one could do all development work in the interpretive environment (break a program at predetermined point, on condition, etc and examine variable information). Because of the p-threading nature (I think) of PDS 7.1 it was practically almost as fast as a stand alone .exe which you could also easily create. So the .exe did not really need special condition checking or fancy error code settings in the program, as in the development/debug stage (using the interpretive environment) one would have hopefully sorted out all the possible bugs. QB64 effectively only works by development testing of the compiled exe.

I have previously suggested that QB64 go along the path of interpretive based (like PDS 7.1) and a few other forum members also support this. However there are forum members (including developers it seems) that are opposed to interpretive based version of QB64. So thirty years ago it was "less painful" to develop, debug and test a BASIC program, and when working, one would create the .exe file then.

In many ways, I still prefer using PDS 7.1 over QB64, because of what mentioned above - but obviously because of hardware improvements over the past 30 years, PDS 7.1 is very limited.
Title: Re: in which line am i ?
Post by: bplus on May 27, 2021, 02:42:59 pm
https://www.qb64.org/forum/index.php?topic=458.0 — That’s the closest to all that ole stuff that you’re going to come.

oh?
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:43:58 pm
yes Richard, your suggestion is very good! You wouldn't even need an interpreter here! When we run the exe and press ctrl + break, the exit occurs. I’m sure something stores the line. (I think if there is an error, you know). This should just be printed out!
Title: Re: in which line am i ?
Post by: MasterGy on May 27, 2021, 02:46:23 pm
if it were in qb 7.1 _MAPTRIANGLE and I would also use it because of the things listed :)
Title: Re: in which line am i ?
Post by: Richard on May 27, 2021, 03:28:40 pm
Just a bit of a detour...

To attempt to take advantage of all QB64 features and still have superior features from the past (PDS 7.1) - I experimented having a "dual environment" (for want of a better term) for my development work. Basically it involved the following...

Generate the QB64 program as usual (running as first instance of QB64).
Open up a second instance of QB64 ( and say have a red IDE background).
The second instance of QB64 has a program to read your first instance program and does some modifications to a copy of your program such as inserting line labels (which are exactly the line numbers you see in the IDE of the first instance i.e. your program under development). Also can insert all sorts of things like program breakpoints, display eg on the title bar or console window, disk file, etc, etc of variables, relative timings, history, events. Effectively the second instance of QB64 has a "bloated" version of your original program, it will run much slower, simultaneously display/save  all the variables you choose, etc. By automatically inserting (in the second instance) a "universally used subroutine" - you could single step (forward or backward) or branch elsewhere.
Once the "bloated" program (QB64 instance #2) is setup, run this to debug. Because the line labels correspond to your original program (QB64 instance #1), it is easy to find where to edit as necessary the original program.

A big disadvantage of my approach is that if you edit the "bloated" program ie to make it work, your original program will not be updated. The idea of dual instances of QB64 accessing the exact same program/file with automatic updating of the IDE was rejected - was advised to use say NotePad instead of the second instance.
Title: Re: in which line am i ?
Post by: SpriggsySpriggs on May 27, 2021, 04:06:04 pm
It sounds like you are suggesting to use vWatch, which is a program made by Fellippe for debugging QB64 programs :)
Title: Re: in which line am i ?
Post by: luke on May 28, 2021, 04:35:24 am
Well, here's one way to do it:

Enable debug symbols under Options -> Advanced

Compile your program. Here's mine:
Code: [Select]
Print "hello"

While 1
    Print "world"
    For i = 1 To 10
        Print i
    Next i
Wend

Launch the program under gdb and run it:
Code: [Select]
$ gdb untitled
Reading symbols from untitled...done.
(gdb) run

When you think your program is stuck, kill it with ^C and switch to thread 2:
Code: [Select]
^C
Thread 1 "untitled" received signal SIGINT, Interrupt.
0x00007ffff7d3ebf0 in __GI___nanosleep (
    requested_time=0xb56c10 <Sleep(unsigned int)::ts>, remaining=0x0)
    at ../sysdeps/unix/sysv/linux/nanosleep.c:28
28      ../sysdeps/unix/sysv/linux/nanosleep.c: No such file or directory.
(gdb) thread 2

Get a stack trace:
Code: [Select]
(gdb) bt
#0  __GI___printf_fp_l (fp=fp@entry=0x7ffff55c0bc0, loc=<optimized out>,
    info=info@entry=0x7ffff55c0720, args=args@entry=0x7ffff55c0700)
    at printf_fp.c:1246
#1  0x00007ffff788f7c9 in ___printf_fp (fp=fp@entry=0x7ffff55c0bc0,
    info=info@entry=0x7ffff55c0720, args=args@entry=0x7ffff55c0700)
    at printf_fp.c:1267
#2  0x00007ffff788a54b in _IO_vfprintf_internal (s=s@entry=0x7ffff55c0bc0,
    format=format@entry=0x4cde7d "% .6E", ap=ap@entry=0x7ffff55c0cf0)
    at vfprintf.c:1637
#3  0x00007ffff78ac321 in __IO_vsprintf (
    string=0xb48640 <qbs_str_buffer> " 1.000000E+000", format=0x4cde7d "% .6E",
    args=args@entry=0x7ffff55c0cf0) at iovsprintf.c:42
#4  0x00007ffff7892774 in __sprintf (s=<optimized out>, format=<optimized out>)
    at sprintf.c:32
#5  0x0000000000449876 in qbs_str (value=10) at libqb.cpp:6893
#6  0x00000000004095e7 in QBMAIN (unused=0x0) at ../temp/main.txt:47
#7  0x00000000004091fb in QBMAIN_LINUX (unused=0x0) at qbx.cpp:2084
#8  0x00007ffff7d34fa3 in start_thread (arg=<optimized out>)
    at pthread_create.c:486
#9  0x00007ffff79334cf in clone ()
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Note QBMAIN is at temp/main.txt line 47, so open internal/temp/main.txt and look at line 47:
Code: [Select]
45 do{
 46 tqbs=qbs_new(0,0);   
 47 qbs_set(tqbs,qbs_add(qbs_str((float)(*__SINGLE_I)),qbs_new_txt(" ")));   
 48 if (new_error) goto skip6;   
 49 makefit(tqbs);   
 50 qbs_print(tqbs,0);   
 51 qbs_print(nothingstring,1);   
 52 skip6:
 53 qbs_free(tqbs);   
 54 qbs_cleanup(qbs_tmp_base,0);   
 55 if(!qbevent)break;evnt(6);}while(r);

Line 55 is a code fragment that is generated after every BASIC line (more or less). The call to evnt(6) indicates that the preceeding code, including line 47, corresponds to line 6 in the BASIC source.
Title: Re: in which line am i ?
Post by: MasterGy on May 28, 2021, 04:20:26 pm
thanks Luke, this is an interesting approach! I will study. interesting thing is what else to see with it.