Control keyword & Optimized Compile

Discussion in 'Bug Reports' started by Scubaticus, Jun 17, 2009.

  1. Scubaticus

    Scubaticus Active Member Licensed User

    I have a form called Form1 with a label called Label1

    Sub Globals
    'Declare the global variables here.

    End Sub

    Sub App_Start
       lblName = 
    Control(lblName).Text = "Hello World"
    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):

    An error occurred on sub __main_app_start
    to convert object of type Dbasic.EnhancedControls.CEnhancedLabel to type Dbasic.IText
    This was not a problem with the 6.5
  2. agraham

    agraham Expert Licensed User

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

    Looks like a little bugette crept into 6.80!
  3. Scubaticus

    Scubaticus Active Member Licensed User

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

    Sub App_Start
       lblName = 
       cType   = ControlType(lblName)
    Control(lblName, cType).Text = "Hello World"
    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 ....
  4. agraham

    agraham Expert Licensed User

    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.
  5. Scubaticus

    Scubaticus Active Member Licensed User

    Ok, I thought I could solve this like:

    Sub App_Start
       Name    = 
       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
    End Sub
    Guess what? It won't compile either. It gives me the error (again translated from dutch):

    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: 
    Select cType
  6. agraham

    agraham Expert Licensed User

  7. Scubaticus

    Scubaticus Active Member Licensed User

    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?
  8. agraham

    agraham Expert Licensed User

    Sorry , I don't understand this. Can you give an example of what used to work and now doesn't?
  9. Erel

    Erel Administrator Staff Member Licensed User

    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:

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice