Search found 1274 matches

by Munair
Jan 10, 2018 12:50
Forum: Sources, Examples, Tips and Tricks
Topic: IsValue vs IsNumeric
Replies: 13
Views: 2880

Re: IsValue vs IsNumeric

you can't claim "boasting rights" on that one I do not mean to. Val() is old and buggy, and should be avoided, in new code (if at all possible). The VAL() function is a very BASIC function and should not have the status deprecated. It is convient and has been part of the language from the...
by Munair
Jan 10, 2018 9:33
Forum: Community Discussion
Topic: FreeBASIC Namespace Project
Replies: 72
Views: 14076

Re: FreeBASIC Namespace Project

marcov wrote:And who said QB was standard compliant to begin with ?
You'd have to go to TrueBASIC for that if I'm not mistaken. Victor just liked QB very much, as did many others at the time, including me. FreePascal came about in the same way, while TP was also not standard or ISO Pascal compliant.
by Munair
Jan 10, 2018 7:06
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

The VAL() function doesn't understand '-&' as the start of a valid number format. The VAL() function understands what it is programmed to do. Currently, a minus+ampersand combination at the start is considered not-numerical, which I would consider inconsistent. I covered this and another incons...
by Munair
Jan 10, 2018 6:59
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

sancho3 wrote:@munair:
Glad to see that this method is used by programmers other than me. It gives me some confidence.
The final functions are covered in a new thread. Confidence comes from testing. ;-)
by Munair
Jan 09, 2018 16:17
Forum: Community Discussion
Topic: FreeBASIC Namespace Project
Replies: 72
Views: 14076

Re: FreeBASIC Namespace Project

There is always the possibility of a migration tool to make the transition to new incompatible concepts easier. Change is inevitable. Trying to hold on to 10+ years old concepts won't benefit the compiler and the language in general. More possibilities and new powerful features should always be cons...
by Munair
Jan 09, 2018 8:34
Forum: Sources, Examples, Tips and Tricks
Topic: IsValue vs IsNumeric
Replies: 13
Views: 2880

Re: IsValue vs IsNumeric

It would be up to a parser/lexer to locate separators and isolate the code to be identified.
by Munair
Jan 09, 2018 8:24
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

In regards to the keywords, I set up a very fast method of matching them. Including macros there are more than 500 of them. I have them in data statements and I read them into an array. They are already in alphabetical order but sorting them wouldn't take long if need be. I create an index as I am ...
by Munair
Jan 08, 2018 23:39
Forum: Sources, Examples, Tips and Tricks
Topic: IsValue vs IsNumeric
Replies: 13
Views: 2880

IsValue vs IsNumeric

Following a recent thread on code parsing, it became clear that evaluating source code is quite different from evaluating a simple input field if it comes to numeric values. The first requires a lexer or code parser, while the second would do with the VAL() function. To show you the difference, here...
by Munair
Jan 08, 2018 23:08
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

Sure, but I wouldn't rule out the VAL() behaviour, because it's confusing if one doesn't know. But then again, VAL() isn't generally used to parse code. But it can be valuable if a user is required to input a valid number. Hence my proposal to have two different procedures. Worth a new tread I would...
by Munair
Jan 08, 2018 21:43
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

Perhaps two procedures should be used: one to evaluate a specific string as would val do, and another to parse code.
by Munair
Jan 08, 2018 21:35
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

You can check the first char. If it's a leading minus, eat it and pass the remainder of the string to val(). Then, if it's a valid number, negate it. This stems from the situation I explained above (the sign being part of the whole term, not the factor). It appears that FB is inconsistent here: dim...
by Munair
Jan 08, 2018 20:59
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

The following string is also a valid number in FB and reports incorrectly in your code: ? isnumeric("-&hff") ? -&hff #print typeof(&hFF) #print typeof(-&hFF) I went by what VAL() returns and it appears that a minus sign before ampersand is invalid (returns 0): dim s as str...
by Munair
Jan 08, 2018 15:58
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

In QuickBASIC it wasn't possible to use the VAL() function in a IsNumeric test without error trapping because of possible overflow errors (if the number held by a string would be very large). In FreeBASIC this is not a problem so a IsNumeric function could simply use VAL() or test for NULL: function...
by Munair
Jan 08, 2018 10:20
Forum: General
Topic: Code parsing question
Replies: 74
Views: 6077

Re: Code parsing question

Thanks for sharing.
by Munair
Jan 05, 2018 21:26
Forum: General
Topic: Returning Object as Function Result
Replies: 15
Views: 1191

Re: Returning Objects as Function Result

Nice example.