PDA

View Full Version : strange bug: missing close parens



ReneMiner
11-10-2014, 10:14
i have some strange bug...


Edit: seems I found a reason, Type_Exists does not return true for standard types?

old content moved to thinBasic support-area (http://www.thinbasic.com/community/project.php?issueid=473#note2769) .


I use this for something else now:

assume


uses "console"

Type t_Type
abcd As Function
efgh As Function
End Type

Function t_Type.abcd() As String
End Function

Function t_Type.efgh() As Long
End Function

Dim foo As t_Type

PrintL "Test 1 " & $CRLF
' no printout to await but surprise...

If foo.abcd() = "String" Then PrintL "foo.abcd returns string"
If foo.abcd() = "Long" Then PrintL "foo.abcd returns long"
If foo.efgh() = "String" Then PrintL "foo.efgh returns string"
If foo.efgh() = "Long" Then PrintL "foo.efgh returns long"

PrintL $CRLF & "Test 2 " & $CRLF

Select Case foo.abcd()
Case "String"
PrintL "foo.abcd contains string"
Case "Long"
PrintL "foo.abcd contains long"
End Select

Select Case foo.efgh()
Case "String"
PrintL "foo.efgh contains string"
Case "Long"
PrintL "foo.efgh contains long"
End Select

WaitKey



what's going on here?

ErosOlmi
11-10-2014, 18:36
I will have a look ...

ErosOlmi
11-10-2014, 18:45
I think the logical testing is not aware of the possibility to have TYPE Functions as initial parameters and understand if it is a string or numeric logical test comparison.
So the logical test will always result to true.

Thanks for finding it. I will work on it asap.

Eros

ReneMiner
12-10-2014, 09:28
just to hold the thought, chatbox is sometimes unreliable...

Were it an idea to have type-functions that return string (or udts) the function-names mandatory need to end with $ ?

ErosOlmi
12-10-2014, 09:34
just to hold the thought, chatbox is sometimes unreliable...
Confirm. Will try to think something different.


Were it an idea to have type-functions that return string (or udts) the function-names mandatory need to end with $ ?
Thanks for trying to help but that is not the problem.
I know what kind of data a function method does.

My problem is how to return that data when it is a string and the expression is numeric.
"IF [String] = [String] THEN ..." is in reality a logical test that should return a numerical value while inside there are strings.
I perfectly know how to solve it but it is actually inside a very complex part of thinBasic Core engine. I need a little more time to solve it.

ReneMiner
12-10-2014, 15:25
i'm certain you'll find a way but it's probably a matter of insufficient time to do it ... :D
but what have you done with Type_Exists - didn't that work before? I thought so but i'm not sure any more...

ErosOlmi
14-10-2014, 13:00
I think I've solved this problem but ... found another weird one.
When a TYPE function is used into a

SELECT CASE udt.function()
...

it is executed twice.

This because SELECT CASE need to know what kind of data it is examining (numeric or string) making an ahead evaluation and the function used to do that is also executing the function.
I need to separate the two phases.

ReneMiner
14-10-2014, 13:18
sounds if everything were under control - i don't want to post loads of examples but i think

If- conditions are somewhat similar to While/Until i guess

What about Iif/Iif$ ? shall i try out?

ErosOlmi
15-10-2014, 15:23
I should have fixed these problems.
In few hours I will post an updated thinCore.dll

ErosOlmi
15-10-2014, 15:55
Here a thinCore.dll

Hope it works fine for the above 2 problems:

IF with TYPE Functions
SELECT CASE ... using TYPE Functions


If OK, I will publish 1.9.14 and start working on next requests.

ReneMiner
15-10-2014, 16:42
seems all fine what that is about. not returning any values if none gets assigned in the function any more :D


Uses "console"
PrintL IIf$(type_Exists("Long"), "long exists", "long does not exists")
WaitKey

;) -

ps. sorry for the many ideas i have currently... if you need a challenge- see support (http://www.thinbasic.com/community/project.php?projectid=1)