Author Topic: Interesting IDE effect noticed  (Read 5495 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Interesting IDE effect noticed
« on: August 25, 2018, 10:31:34 am »
I've come across an interesting issue with the IDE. I've been programming a role playing character generator and it uses several user defined variable types. My IDE colors are set to the QB64 default setting. Variables are bright white and keywords are light blue.

Here is one of my variable types:

TYPE skill
    ident AS INTEGER 'unique ID # of skill
    name AS STRING * 18 'name of skill
    category AS STRING * 4 'category of skill
    value AS INTEGER 'percentage of skill
    base_per AS INTEGER 'base of skill
    cat_per AS INTEGER 'category modifier
    modified AS INTEGER 'number of modifications
    exchk AS INTEGER 'experience check flag
END TYPE

Now the funny thing is, the 'name AS STRING * 18' element, unlike the rest of the elements, displays the "name" in keyword color, instead of white as the others are. There are two more variable types defined that also use 'name' as an element and they display the same way. I know now (having looked it up) that NAME is a keyword, which I do not use in its keyword capacity any where in the program, nor does it color the '{variable}.name' anywhere else in the program except within the TYPE declaration, but here's where it gets a little wierd.

It displays as the keyword color, but doesn't attempt to capitalize 'name', nor does the program have any errors related to that element. It runs just as expected in that respect. No issues that I can see.

Have I found a quirk of the IDE's keyword recognition, and does anyone think I should be changing the element as a precaution?

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Interesting IDE effect noticed
« Reply #1 on: August 25, 2018, 11:20:21 am »
Name is a reserved word in Qbasic therefore the IDE is probably coloring it as such. More than likely the IDE will need a little tweaking to skip reserve word checks inside of TYPE constructs.
In order to understand recursion, one must first understand recursion.

FellippeHeitor

  • Guest
Re: Interesting IDE effect noticed
« Reply #2 on: August 25, 2018, 11:42:38 pm »
The way QB64's syntax highlighter currently works is by analyzing each visible line of code and checking, character by character, against (i) a list of internal commands names, (ii) the list of user-defined keywords (check internal/config.txt for instructions on how to add custom keywords and (iii) user's SUB/FUNCTION names. No check at all is made concerning scope, which would solve this problem, but that doesn't mean it can't be done in a future release.

I thank you guys for reporting it, although it was already known - one of those things you let slip and hope no one will complain about. Guilty as charged.
« Last Edit: August 25, 2018, 11:54:21 pm by FellippeHeitor »

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Interesting IDE effect noticed
« Reply #3 on: August 26, 2018, 12:42:04 am »
I remember the IDE from way back in .8x days of QB64. It has come a long way since then. A little highlighting glitch is nothing compared to the rich features it offers today. Heck, back then there was no highlighting at all. Thanks for keeping the IDE up to date Fillippe!
In order to understand recursion, one must first understand recursion.

FellippeHeitor

  • Guest
Re: Interesting IDE effect noticed
« Reply #4 on: August 26, 2018, 12:48:44 am »
My pleasure, Terry!

Thanks also to Steve's effort, who implemented the embryo for the current expanded highlight implementation.

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Interesting IDE effect noticed
« Reply #5 on: August 26, 2018, 01:01:40 am »
Thanks also to Steve's effort, who implemented the embryo for the current expanded highlight implementation.

Oh I didn't know that. Cool, thanks Steve! :)
In order to understand recursion, one must first understand recursion.

Marked as best answer by OldMoses on August 26, 2018, 03:42:25 pm

FellippeHeitor

  • Guest
Re: Interesting IDE effect noticed
« Reply #6 on: August 26, 2018, 01:09:46 am »
Have I found a quirk of the IDE's keyword recognition, and does anyone think I should be changing the element as a precaution?

No need to change the element name at all, unless the highlight in the TYPE block bothers you (the element won't be highlighted any different when used in variable names later - see screenshot below).

 [ You are not allowed to view this attachment ]  

Other than that, no issues for the workings of your program at all.
« Last Edit: August 26, 2018, 01:13:36 am by FellippeHeitor »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Interesting IDE effect noticed
« Reply #7 on: August 26, 2018, 05:26:34 pm »
As a related issue:

Since  QB64 doesn't work with FN, and since FN isn't a reserved keyword (it's a perfectly valid variable name), shouldn't it be excluded from the reserved word list, which is used to color/highlight the text?

DIM SHARED FW AS ObjectDimensions, FN  AS ObjectDimensions, FE AS ObjectDimensions, FS AS ObjectDimensions

The above code colors FN blue in the idea, just as it would any other reserved keyword -- even though it's a perfectly valid variable name.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: Interesting IDE effect noticed
« Reply #8 on: August 26, 2018, 05:31:51 pm »
Definitely!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Interesting IDE effect noticed
« Reply #9 on: August 26, 2018, 05:52:14 pm »
Here is one I ran into yesterday using QB64x64 but it also is on latest Beta. Usually the IDE changes case of variable spelling to match the first one it finds but in ubound and now I see lbound, not so, still it does not effect performance.

FellippeHeitor

  • Guest
Re: Interesting IDE effect noticed
« Reply #10 on: August 26, 2018, 05:54:32 pm »
That's known (and old) too. Never figured how to fix it.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Interesting IDE effect noticed
« Reply #11 on: August 26, 2018, 06:12:28 pm »
Hi QB64 developers
just a question for curiosity, to let know and no other matter.

it is OK that FN is not implemented!
it is OK that to port a Qbasic/QB code, that uses FN functions, to QB64 it is possible rewrite the FN function as Function..... End Function

Who  does remember the matter that brings FN out of supported QB's  keywords?
Thanks
Programming isn't difficult, only it's  consuming time and coffee

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Interesting IDE effect noticed
« Reply #12 on: August 26, 2018, 06:49:37 pm »
Have I found a quirk of the IDE's keyword recognition, and does anyone think I should be changing the element as a precaution?

No need to change the element name at all, unless the highlight in the TYPE block bothers you (the element won't be highlighted any different when used in variable names later - see screenshot below).

Other than that, no issues for the workings of your program at all.

Thanks, I thought it would be OK, but it's nice to have verification.

I'll also take this opportunity to thank you guys for QB64, it's so nice to resurrect old programs, escape DOS emulators, have mouse support, etc., etc.

I've just spent the afternoon playing with _NEWIMAGE, _RGB32, et. al. So much to see and do, my head might explode...;)

Offline TerryRitchie

  • Seasoned Forum Regular
  • Posts: 495
  • Semper Fidelis
    • View Profile
Re: Interesting IDE effect noticed
« Reply #13 on: August 26, 2018, 11:47:07 pm »
I've just spent the afternoon playing with _NEWIMAGE, _RGB32, et. al. So much to see and do, my head might explode...;)

That's exactly how I felt when first discovered QB64 back in 2010. I was like a kid in a candy store.
In order to understand recursion, one must first understand recursion.