Author Topic: No navigation for Label made by LineNumber  (Read 9513 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
No navigation for Label made by LineNumber
« on: December 09, 2018, 09:31:32 am »
Hi Guys

just playing with Labels....

in old BASIC (IMHO like BASICA and GWBASIC) linenumber is already a label to use for instructions like GOTO and GOSUB...
but also in QBASIC and QB of DOS time if you want to use a linenumber as label you must write it at beginning of the  you must specify the number of the line (indeed you can use also as you will  not sequential linenumber for this purpuse) also without : at the end for defining the label.
In the same QB if you use the menu command find Label it is able to find only linenumbers that have : after them!
But both onlyNumber of line of code both linenumber of code plus : works for GOTO and GOSUB instructions.

In a similar fashion QB64 IDE doesn't let us jump to a specific linenumber of code, also is used as label for a jump instruction, in the while it let us to jump to the other labels like Namelabel :

Moreover the DAV'sIDE let jump to any linenumber but then it depends from QB64 compiler for the other operations.

If you want to do this experience please copy this code into the QB64IDE

Code: QB64: [Select]
  1. 1 SCREEN 0
  2. 2 WIDTH 80, 25
  3. 3: CLS
  4. 4 LOCATE 2, 2: COLOR 14, 1
  5. 5 PRINT " Press ESCAPE for quitting"
  6. 6 LOCATE , 2
  7. 7 PRINT "Press S to stamp message on screen"
  8. 8 LOCATE , 2
  9. 9 PRINT "press C to clear message on screen"
  10. 10
  11. 11 start:
  12.     CASE CHR$(27)
  13.         END
  14.     CASE "S"
  15.         GOTO 23
  16.     CASE "C"
  17.         GOTO 3
  18.     CASE ELSE
  19. 21 GOTO start
  20. 22
  21. 23 LOCATE 24, 2: PRINT " You want this message on screen";
  22. 24 GOTO start
  23.  
then goto on 21 line of code on the start: label and make rightclick... you can jump to start: label, but you cannot jump to
label 3:  and to linenumber 23 also if they are used as labels too.

Is this a case to uniform the behaviour of navigation into code of QB64IDE?

Thanks
Programming isn't difficult, only it's  consuming time and coffee

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #1 on: December 09, 2018, 10:24:25 am »
Line numbers are probably considered depreciated. Most coders use labels now. Maybe that's why it wasn't added to the QB64 IDE. rather than an oversight.

I thought this was smart in QB64 IDE...

ON a GOSUB start, go

So we have two labels, start and go. If you position the mouse on "start" and right click, it asks if you want to jump to the start label, but if instead you position the mouse cursor on "go" and right click, it asks if you want to jump to the go label.

If the developers wanted to add jump to line numbers, I don't think it would be very involved. Maybe you can convince one of them.

Pete

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #2 on: December 09, 2018, 10:38:51 am »
I am not seeing a problem?
« Last Edit: December 09, 2018, 10:53:56 am by bplus »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #3 on: December 09, 2018, 10:51:17 am »
No, no, no! Stop online shopping for skirts from Mars.com and pay attention. Temp is describing the actions of the IDE with the code, not running the code. The IDE has a right click function to jump to line labels, but not line numbers.

Pete :D
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #4 on: December 09, 2018, 10:54:44 am »
OK goto line # works too.
« Last Edit: December 09, 2018, 10:57:48 am by bplus »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #5 on: December 09, 2018, 11:09:42 am »
Oh he still doesn't get it!

1) Paste Temp's code in the IDE.

2) Left click line 24, "GOTO start"

3) Now RIGHT click "start"

... A selection window opens and one of the selections ask if you want to jump to the start label.

Now do the same on the line displaying "GOTO 23"

...If you RIGHT click on the "23" it won't give you the option, in the selection window, to jump to line 23. That's what Temp is discussing.

And yes, stick with basic black. It's after Labor Day, so the white Martian skirt is just simply out of the question. :D

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #6 on: December 09, 2018, 11:13:55 am »
The title of this thread says there is "No navigation for Label made by LineNumber" but there is. :D

OK must be having to type the line number in, that's the problem? ;-))
« Last Edit: December 09, 2018, 11:17:31 am by bplus »

FellippeHeitor

  • Guest
Re: No navigation for Label made by LineNumber
« Reply #7 on: December 09, 2018, 11:16:31 am »
When QB64 parses your code it fills an array with information on labels created by the user. When I wrote the contextual menu in the IDE, I used the information in that array to offer a quick navigation to where the label is created.

Right click a label name next to a GOSUB/GOTO statement and the contextual menu will look like this:

  [ You are not allowed to view this attachment ]  

I did not make any effort to add the same functionality to line numbers because (i) they were already deprecated (what is it with you natives mistaking this with deprec*i*ated?) back in QBasic days, although supported, and are by far not recommended practice and also because (ii) it'd be much more work and would also involve having to parse every line of code with any type of math and literal numbers in it to check if such numbers eventually referred to a valid line number - that is, too much work to provide functionality for a *deprecated* method.

PS: You will also notice that right-clicking a label name when the program doesn't finish parsing (when an error is found and you don't have "OK" in the status bar) will probably not offer the contextual menu shortcut either because the array list stops being created once a syntax error is encountered.
« Last Edit: December 09, 2018, 11:19:35 am by FellippeHeitor »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #8 on: December 09, 2018, 11:32:47 am »
It doesn't matter. Deprecated will be obsolete in a few years, anyway! :D

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #9 on: December 09, 2018, 02:01:26 pm »
Hi
1. Thanks for attention
 at this point of discussion we have reached the real issue about Linenumber as Label

please follow my experience

pasting my code posted above

1. right click on the 16th line of code in the SELECT CASE
Quote
GOTO 23
and you got no link to jump to 23 line of code used as label....

2. right click on the 18th line of code in the SELECT CASE
Quote
GOTO 3
and you got link to jump to line 3 of code used as label....

What I want to note is that the only difference between line of code 3 and line of code 23 is the : used in QB to define a label.

Must the IDE use a one method of manage labels?

@Fellippe
my intention is not to increase your work in QB64 implementation
only to say that the jump instructions are very few... GOTO, GOSUB, ON  variable GOTO...
I don't remember if  IF condition GOTO is correct in QB...
Thanks again

Programming isn't difficult, only it's  consuming time and coffee

FellippeHeitor

  • Guest
Re: No navigation for Label made by LineNumber
« Reply #10 on: December 09, 2018, 02:09:45 pm »
I'd like to see a screenshot of that. We are definitely not seeing the same thing.

Right clicking the 18th line of code that says "GOTO 3" I still get no link to jump to line 3, regardless of it having a colon (:) or not.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #11 on: December 09, 2018, 02:26:45 pm »
I don't see it either, and I tried the current and two older versions. All treated 3: or 23 the same. The colon made no difference and no "Jump to..." selection was displayed in right click menu. I would think QB64 was made to ignore colon(s) placed directly after a line number. So yes, a screen shot and the version number of the IDE would help us see what Temp is seeing.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #12 on: December 09, 2018, 05:40:29 pm »
Hi
1.
I must agree with you (nothing rises up in either the situations...and because I am not able to reproduce  also i again these results... sob!? What can do a glass of good wine like Vulka! Just 12° )  and I'm sorry...

2.
Just to not waste your time and your efforts to answer me I go on with linenumber issue but it is no a my need.

thinking about the list of labels already made by QB64 parser ...

I must imagine that to get no error no linenumber or label there must be in the code a linenumber (a number with/without :) or a label (descriptor + :) that the parser can find...

in this case linenumber (in the parser view) is just a label with exception of : at the end of the name

if it is so... we can use  linenumber with value inverse to their position and the code works in the same manner....

Code: QB64: [Select]
  1. 25 SCREEN 0
  2. 24 WIDTH 80, 25
  3. 23 CLS
  4. 22 LOCATE 2, 2: COLOR 14, 1
  5. 21 PRINT " Press ESCAPE for quitting"
  6. 20 LOCATE , 2
  7. 19 PRINT "Press S to stamp message on screen"
  8. 18 LOCATE , 2
  9. 17 PRINT "press C to clear message on screen"
  10. 16
  11. 15 start:
  12.     CASE CHR$(27)
  13.         END
  14.     CASE "S"
  15.         GOTO 3
  16.     CASE "C"
  17.         GOTO 23
  18.     CASE ELSE
  19. 5 GOTO start
  20. 4
  21. 3 LOCATE 24, 2: PRINT " You want this message on screen";
  22. 2
  23. 1 GOTO start
  24.  

and it seems to work in the same manner....

so I can argue that parser already does this work to check the being of the label or linenumber pointed by a Jump instruction...
and when it puts a label into the list, it is already able to put linenumber of Jump instruction

from wiki the jump instructions are:
Quote
ON COM(n) (event statement) executes when there is a value in the serial port specified. NOT IMPLEMENTED!
ON ERROR GOTO (event statement) executes when a program error occurs
ON KEY(n) (event statement) executes when a keypress or keypress combination occurs.
ON PEN (event statement) executes when a PEN event occurs. NOT IMPLEMENTED!
ON PLAY(n) (event statement) executes when the background music queue is low. NOT IMPLEMENTED!
ON STRIG(n) (event statement) executes when a joystick button event occurs. NOT IMPLEMENTED!
ON STRIG(n) (event statement) directs program flow upon a button press event of a game controller device.
ON TIMER(n) (event statement) executes when a timed event occurs. QB64 can use multiple numbered timers.
ON UEVENT (event statement) executes when a user event occurs. NOT IMPLEMENTED!
ON...GOSUB (event statement) branches to a line number or label according to a numerical ordered list of labels.
ON...GOTO (event statement) branches to a line number or label according to a numerical ordered list of labels.
IF conditionStatement GOTO lineLabel
and of these only 9 are implemented!

and just to close with a smile here my spaghetti code...
Code: QB64: [Select]
  1. 25 SCREEN 0
  2. 24 WIDTH 80, 25
  3.  
  4. 1600
  5. LOCATE 3, 2: PRINT " press I for IF..GOTO or O for ON...GOTO";
  6. b$ = UCASE$(INKEY$): PRINT " "; b$: _DELAY .5
  7. IF b$ = "I" GOTO 23
  8. IF b$ = "O" GOTO 101
  9. GOTO 1600
  10.  
  11. 23 CLS
  12. 22 LOCATE 2, 2: COLOR 14, 1
  13. 21 PRINT " Press ESCAPE for quitting"
  14. 20 LOCATE , 2
  15. 19 PRINT "Press S to stamp message on screen"
  16. 18 LOCATE , 2
  17. 17 PRINT "press C to clear message on screen"
  18.  
  19. 15 start:
  20. 14 A$ = UCASE$(INKEY$)
  21. 100
  22. 8 IF A$ = CHR$(27) THEN END
  23. 7 IF A$ = "S" GOTO 3
  24. 6 IF A$ = "C" GOTO 23
  25. 5 GOTO start
  26. 4
  27. 3 LOCATE 24, 2: PRINT " You want this message on screen";
  28. 2
  29. 1 GOTO start
  30.  
  31. 101
  32. LOCATE 2, 2: COLOR 14, 1
  33. PRINT "Press 1 for quitting"
  34. LOCATE , 2
  35. PRINT "Press 2 to stamp message on screen"
  36. LOCATE , 2
  37. PRINT "press 3 to clear message on screen"
  38.  
  39.  
  40.  
  41. 102 A = VAL(INKEY$)
  42. ON A GOTO 500, 33, 101
  43. GOTO 102
  44.  
  45. 33 LOCATE 24, 2: PRINT " You want this message on screen";
  46. GOTO 102
  47.  
  48. 500 END

Try it! It must be good, spaghetti is italian food!
:-)

Programming isn't difficult, only it's  consuming time and coffee

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #13 on: December 09, 2018, 06:29:02 pm »
Actually spaghetti is Chinese but when Italians make it, you're not still hungry afterwards!

Well, that's not exactly true... although spaghetti is Sicilian, and being part Sicilian I can tell you that has almost nothing to do with being Italian! The Chinese did have a form of pasta though.

Anyway "Italian pasta is different from the Chinese one, ingredients and way of preparing." taken from a website article.

Don't worry about the line number thing. It was an interesting conversation.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: No navigation for Label made by LineNumber
« Reply #14 on: December 10, 2018, 09:04:17 am »
Ah! now I see, Menu Search > Go to line... say 23, in Editor, goes to the 23rd line of code that is marked 3 in sample code (with line numbers reversed). That is a problem if you wanted the line that starts with 23(space).

(Also I note the cursor is placed past the end of the line, whereas the cursor is placed at the start of the line when finding line labels with right mouse click on label name.)

Well, if desperate there is still search "23(space)" to find line labeled 23 and of course it will stop at every 23(space) on the way to the line label with a number 23.