Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Beta Versions
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Beta Versions This forum is the place to discuss issues regarding Basic4ppc beta versions.

Boolean problem

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-27-2010, 05:31 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default Boolean problem

In the IDE this code does not error but does not behave correctly when ANDing a Boolean with another Boolean or a True or False literal value. It immediately exits the IF block without executing the Msgbox statement. It does throw an error if you try to compile. OR doesn't work either but NOT() seems to be OK

Code:
Sub test
    
Dim b As Boolean
    
If b = False Then
        b = b 
AND True
        
Msgbox(b)
    
End If
End Sub
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #2 (permalink)  
Old 02-27-2010, 06:30 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 762
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Possibly unrelated, but...

I have been "getting away with" having a Sub declared "As Boolean" (dating back to when I thought that was valid).

But when I tried to compile with the new beta version I got a complaint "cannot implicitly convert type 'string' to 'bool'" (as attached). The Sub has a number of Return statements which all use "False" or "True" values, as you might expect. The error message points to the last line of the Sub.

I had wondered if the built-in constants have implied types in the new language.

Mike.
Attached Images
File Type: jpg coerce problem.jpg (14.6 KB, 8 views)
Reply With Quote
  #3 (permalink)  
Old 02-27-2010, 06:49 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Are you using the latest 6.851? I've tried Subs that return Booleans and it works for both variables and False and True keywords and "False" and "True" as string literals. Even the default return value from End Sub properly returns false.

What does your Sub declaration look like. It looks like the Sub is returning a string value.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.

Last edited by agraham : 02-27-2010 at 06:54 PM.
Reply With Quote
  #4 (permalink)  
Old 02-27-2010, 10:46 PM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 762
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
Are you using the latest 6.851? I've tried Subs that return Booleans and it works for both variables and False and True keywords and "False" and "True" as string literals. Even the default return value from End Sub properly returns false.

What does your Sub declaration look like. It looks like the Sub is returning a string value.
Yes, I'm running (it says) 6.851.

Code:
Sub openFile(activity, inOut, saveFile) As Boolean
Immediately before the End Sub there is an ErrorLabel(openFileErrHandler) portion which also has its own Return False.

Mike.
Reply With Quote
  #5 (permalink)  
Old 02-28-2010, 09:37 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I see it now, only when optimised compiled. The problem is caused by the Errorlabel statement which emits a code structure with a default return of an empty string at End Sub instead of a Boolean.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #6 (permalink)  
Old 02-28-2010, 10:46 AM
Basic4ppc Expert
 
Join Date: May 2008
Location: Berkshire, UK
Posts: 762
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
The problem is caused by the Errorlabel statement which emits a code structure with a default return of an empty string at End Sub instead of a Boolean.
Thanks Andrew, I guess there isn't going to be a work-around for that (other than omitting the "As..") without a fix from Erel.

Mike.
Reply With Quote
  #7 (permalink)  
Old 02-28-2010, 04:52 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

There was a bug with the combination of ErrorLabel and return types different than strings. It is now fixed.

Currently AND and OR are not supported outside an explicit condition statement (if, while, select...).
__________________
Basic4android documentation
Reply With Quote
  #8 (permalink)  
Old 02-28-2010, 06:17 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Erel View Post
Currently AND and OR are not supported outside an explicit condition statement (if, while, select...).
I've been trying to see how you could use AND or OR in a Select and I can't find a way that works. What am I missing
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #9 (permalink)  
Old 02-28-2010, 06:42 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

OOPS. You are not missing anything...
__________________
Basic4android documentation
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
reverse boolean? RB Smissaert Questions (Windows Mobile) 5 03-31-2009 05:01 PM
Conditional check failing for a Boolean type agraham Bug Reports 9 01-03-2008 01:22 PM


All times are GMT. The time now is 09:12 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0