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

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

Bug Reports Post about errors or bugs encountered.

Control keyword & Optimized Compile

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-17-2009, 09:59 PM
Senior Member
 
Join Date: Jun 2007
Location: Netherlands (Arnhem)
Posts: 107
Awards Showcase
Beta Tester 
Total Awards: 1
Default Control keyword & Optimized Compile

I have a form called Form1 with a label called Label1

Code:
Sub Globals
    
'Declare the global variables here.

End Sub

Sub App_Start
    lblName = 
"Main.Label1"
    Control(lblName).Text = 
"Hello World"
    Form1.Show
    
End Sub
On the desktop it executes normally.
Not optimized compiled (Windows Exe) executes normally
Optimized compiled (Windows Exe) crashes with a message (translated from Dutch so originally it will look a little bit different):

Code:
An error occurred on sub __main_app_start
Unable 
to convert object of type Dbasic.EnhancedControls.CEnhancedLabel to type Dbasic.IText
This was not a problem with the 6.5
__________________
PPC: IPAQ 2210, 2GB, CF GPS, CF Wireless
Mobile: Samsung Omnia I900 (WM6.1)
Reply With Quote
  #2 (permalink)  
Old 06-18-2009, 08:14 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

"Control(lblName, Label)" fixes it although according to the Help->MainHelp->Keyword->Runtime control manipultion->Control it should not be necessary

Quote:
As of version 6.00, the compiler may ask you to specify the control's or object's type.

The following properties does not require you to specify the type:

Text, Left, Top, Width, Height, Visible, Enabled, Focus, BringToFront, Color, FontColor, FontSize, Refresh, Dispose, Name, Image, Checked, IgnoreKey, SelectionLength, SelectionStart, ScrollToCaret, Multiline and LoadPicture.
Looks like a little bugette crept into 6.80!
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #3 (permalink)  
Old 06-18-2009, 09:25 AM
Senior Member
 
Join Date: Jun 2007
Location: Netherlands (Arnhem)
Posts: 107
Awards Showcase
Beta Tester 
Total Awards: 1
Default

I tried to fix this problem internally because I use the Control keyword a lot:

Code:
Sub App_Start
    lblName = 
"Mod1.Mod1Label1"
    cType   = ControlType(lblName)
    Control(lblName, cType).Text = 
"Hello World"
    Mod1.Mod1Form.Show
    
End Sub
But it won't compile this way as 'cType' is not a controltype.
Now i have to recode it into Select Case statements ....
__________________
PPC: IPAQ 2210, 2GB, CF GPS, CF Wireless
Mobile: Samsung Omnia I900 (WM6.1)
Reply With Quote
  #4 (permalink)  
Old 06-18-2009, 09:50 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Scubaticus View Post
But it won't compile this way as 'cType' is not a controltype.
No it won't. It can't be a variable as the compiler needs to know the control type at compile time in order to emit the correct code for the type of control.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #5 (permalink)  
Old 06-18-2009, 01:46 PM
Senior Member
 
Join Date: Jun 2007
Location: Netherlands (Arnhem)
Posts: 107
Awards Showcase
Beta Tester 
Total Awards: 1
Cool

Ok, I thought I could solve this like:

Code:
Sub App_Start
    Name    = 
"Mod1.Mod1Label1"
    cType   = ControlType(Name)
    Trans   = 
"Hello World"

    
Select cType
    
        
Case 'Button'
            Control(Name, Button).Text = Trans
            
        
Case 'CheckBox'
            Control(Name, CheckBox).Text = Trans
            
        
Case 'Form'
            Control(Name, Form).Text = Trans
            
        
Case 'ImageButton'
            Control(Name, ImageButton).Text = Trans

        
Case 'Label'
            Control(Name, Label).Text = Trans
            
        
Case 'TextBox'
            Control(Name, TextBox).Text = Trans
            
            
    
End Select
        
    
    Mod1.Mod1Form.Show
    
End Sub
Guess what? It won't compile either. It gives me the error (again translated from dutch):

Code:
Error compiling program.
Error message: The index 
is outside of range. The index may not be negative and should be smaller than the size of the collection.

Line number: 
11
Line: 
Select cType
__________________
PPC: IPAQ 2210, 2GB, CF GPS, CF Wireless
Mobile: Samsung Omnia I900 (WM6.1)
Reply With Quote
  #6 (permalink)  
Old 06-18-2009, 02:03 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

You may have realised this by now but the problem is that your Case statements use single quotes instead of double quotes and so look like comments to the compiler.

Also note that if you include Control(name, type) referencing a control type you don't have in your program it also won't compile http://www.basic4ppc.com/forum/bug-r...ile-error.html
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #7 (permalink)  
Old 06-18-2009, 02:26 PM
Senior Member
 
Join Date: Jun 2007
Location: Netherlands (Arnhem)
Posts: 107
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Oops...was I sleeping or blinded by the 'Line: Select cType' reference for the error.

Anyway, the names of all my controls with labels comes from a database with the value it should become. This is done for translation purpose.

In 6.5 this wasn't a problem at all. As from 6.8 it seems it's not possible anymore to access a control using a string but I have to use a constant instead?
__________________
PPC: IPAQ 2210, 2GB, CF GPS, CF Wireless
Mobile: Samsung Omnia I900 (WM6.1)
Reply With Quote
  #8 (permalink)  
Old 06-18-2009, 02:37 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Scubaticus View Post
In 6.5 this wasn't a problem at all. As from 6.8 it seems it's not possible anymore to access a control using a string but I have to use a constant instead?
Sorry , I don't understand this. Can you give an example of what used to work and now doesn't?
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #9 (permalink)  
Old 06-18-2009, 03:53 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,713
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

I see this bug too. Thanks.
It will be fixed in the next version.
You can apply the fix by replacing CEnhancedLabel.cs with the one attached.
This file should be located under Tzor folder. By default it is:
C:\Program Files\Anywhere Software\Basic4ppc Desktop\Tzor
Attached Files
File Type: zip CEnhancedLabel.zip (1.1 KB, 27 views)
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
Change Control positions and sizes after compile. burd27 Questions (Windows Mobile) 16 04-21-2009 09:36 PM
Control keyword parameters agraham Bug Reports 1 03-24-2009 05:42 PM
Today keyword? JesseW Basic4ppc Wishlist 3 03-21-2009 10:26 AM
Optimized Compile Problem with Control epsharp Questions (Windows Mobile) 6 02-09-2009 05:08 PM
Control.Visible problem in optimise compile agraham Bug Reports 1 01-14-2008 06:54 PM


All times are GMT. The time now is 03:40 PM.


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