Encountered a confusing error message? Please post here

michaelm

Member
Licensed User
Longtime User
error on device

I have just loaded basic4ppc onto my new samsung omnia and Im encountering this error . an error occurred on sub main app_start .
line number 20
table10.loadcsv ("fooddat.csv",",",false true)
Error description : an error message cannot be displayed because an optional resource assembly containing it cannot be found
Continue?

What am I doing wrong?
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
I have just loaded basic4ppc onto my new samsung omnia and Im encountering this error . an error occurred on sub main app_start .
line number 20
table10.loadcsv ("fooddat.csv",",",false true)
Error description : an error message cannot be displayed because an optional resource assembly containing it cannot be found
Continue?

What am I doing wrong?

For the complete error messages look here http://www.b4x.com/forum/code-samples-tips/572-avoid-optional-resource-assembly-cannot-found.html

The problem with your code is here...
B4X:
table10.loadcsv ("fooddat.csv",",",[COLOR="Red"]false true[/COLOR])
It's either false or true not both :)

Regards,
Randomcoder
 

michaelm

Member
Licensed User
Longtime User
In my last post I forgot to put the "," between the words false and true. I do need both because I have no header and I want the column names to be "Column1, column2, etc.

From Main Help:
Loads data to the Table from a CSV file.
Syntax: LoadCSV (File Name, Separator Character, Header Exist, Create Columns)
Separator Character - The character that is used to separate between the values. Usually , (comma)
Header Exist - A boolean that tells if the first row in the file is the columns names (header values) or the file contains only the data.
Create Columns - If set to True, new columns will be created (type - cString). If false the current columns will remain and the data will be added. In the second case the column number and type must match the data.


If HeaderExist is True and CreateColumns is True: New columns will be created named as the values of the first row in file.
If HeaderExist is True and CreateColumns is False: The data will be added to the current columns ignoring the first row in file.
If HeaderExist is False and CreateColumns is True: New columns will be created named Column1, Column2...
If HeaderExist is False and CreateColumns is False: The data will be added to the current columns including the first row in file.
Example:
Table1.LoadCSV ("data.csv", ",", True, True)

I'm new to this so maybe I'm mistaken.
 

Smee

Well-Known Member
Licensed User
Longtime User
Hi All,

This is the code snippet
B4X:
Sub txtCustomer_LostFocus
'Using tblProducts to hold temporary Data
txt=txtCustomer.Text
command.CommandText="SELECT [Customer Code], [Customer], [Address] FROM [Custs] WHERE [Customer Code] LIKE '%" & txt &"%'"
Command.ExecuteTable("tblProducts",0)
'Now load the table values into the label control
txtCustName.Text=tblProducts.Cell("Customer", 0)
txtCustAddress.Text=tblProducts.Cell("Address", 0)
CustCode=tblProducts.Cell("Customer Code", 0)
'Set the combo Control To correct Code
For i = 0 To cboCust.Count-1
    If cboCust.Item (i) = CustCode Then 
        cboCust.SelectedIndex=i    
        Exit
    End If
Next 
btnAccept.Enabled=True
End Sub
When i type in any letter up to trea the code works but if i type in the next letter which is s as in treas then the code does not work

So if i type in t i get 'treasure'
also any other letter in the word up to and including a gives me the same correct result. But when i type in the s the code gives me this error
an error occured on sub main txtCustomer_LostFocus
line no 229
txtCustName.Text=tblProducts.Cell("Customer", 0)
error description:
Index 0 is either negative or above rows count.

What is causing this error?

thanks
 

Smee

Well-Known Member
Licensed User
Longtime User
Maybe no rows are returning in this case?
You can check tblProducts.RowCount to see the number of rows in the table.

Thanks for the reply Erel,

I assumed that that was the case but i cannot understand why no rows are returned for treas when looking for the word treasure but a row is returned for the shorter version 'trea'

Can you shed any light on this because when a search is performed i do not know how ppl will do a search for a particular record


:sign0104:
 
Last edited:

Smee

Well-Known Member
Licensed User
Longtime User
ok i worked it out for anyone's information;

I was inadvertently testing against the Customer Code field which is an indexed field of 5 characters instead of the Customer field hence it only allowed the 'trea' and no further. The index for that field is G12TREA.

thanks for the input Erel

:sign0161:
 

agraham

Expert
Licensed User
Longtime User
This simple program returns the wrong result, without error, in the IDE but fails optimised comilation indicating that the error is on the "End Sub" of App_start whereas it's the semicolon at the end of the line in the For loop that is the problem.
B4X:
Sub Globals
End Sub

Sub App_Start
   Msgbox(DoMaths)
End Sub

Sub DoMaths
   For i = 0 To 10 
      l = l + i;
   Next
   Return l
End Sub
 

Cableguy

Expert
Licensed User
Longtime User
Yes, I have had this same behavior myself..
Anothor one is, in WinMo 6.6, if for any reason an exception is thrown, and, since I do not have the suplementary messages pack installed, I cannot press any other key, other than close the basic4ppc ide, If I try to re-launch the B4Ppc IDE it does Nothing, No error, No IDE, Nothing happens...
 

Cableguy

Expert
Licensed User
Longtime User
Another Error that should NOT be happening...

If a Timer is created programatically, and we try to "clean" the code by setting all the props and linking the event, if the event sub is not codded yet it will error...

B4X:
Sub Whatever
.......
For a = 1 to 3
x= "Timer" & x
AddTimer(x)
Control(x).Enabled = False
Control(x).Interval = 500
AddEvent(x,Tick,x & "_Tick"
Next
........
End Sub

Sub Timer1_Tick '----> If this sub doesnt exist, an NullRef Exception is thrown
End Sub

Yes I know that eventually the event will be added as we will need it, but sometimes I run my code on a "Step-to-Step" basis, and I may have some of the added events still NOT present...
I think that this should not throw an error, but only some "Event missing" notification, as the error prevents all subsequent code from being processed.
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
And another one...

B4X:
For y=1 To 7
   For x=0 To 5
      AddImageButton("Form1","IB"&x&y,15+(y*25),70+(x*25),24,24)
      Control("IB"&x&y,ImageButton).Transparent=True
   Next x
Next y

This creates a 7x6 grid of ImageButtons, and throws NO erros on the IDE...
BUT, if I try to compile....Well, see the error message in the picture below.
 

Attachments

  • untitled.JPG
    untitled.JPG
    15.2 KB · Views: 204

Zenerdiode

Active Member
Licensed User
B4X:
Sub Whatever
.......
For a = 1 to 3
[COLOR="Red"]x= "Timer" & x[/COLOR]
AddTimer(x)
Control(x).Enabled = False
Control(x).Interval = 500
AddEvent(x,Tick,x & "_Tick"
Next
........
End Sub

Sub Timer1_Tick '----> If this sub doesnt exist, an NullRef Exception is thrown
End Sub

Surely that should be;
x= "Timer" & a :confused:
 

Cableguy

Expert
Licensed User
Longtime User
That was just a misstype, as I didn't copy/paste the code...
the code works fine IF the tick sub is present, but I also found out that, standart events for each control do NOT HAVE TO BE ADDED with AddEvent, even if the control itself was added programatically...
 

epsharp

Member
Licensed User
Longtime User
Error Message using Control Keyword

Sub Globals
End Sub

Sub App_Start
Form1.Show
frm = "Form1"
Msgbox(Control(frm,Form).Height)
AddPanel(Control(frm,Form),"Panel1",1,1,237,300)
End Sub

The MsgBox returned 268 which is correct.

The AddPanel generated an error "Index Out Of Range"

:sign0161:

Regards

Ed Sharp

NB: In the real world, I was trying to add a panel to the main form from a module
 

taximania

Well-Known Member
Licensed User
Longtime User
error occurred on sub_main_killlabel

My code works in the desktop IDE
It compiles for desktop OK but throws this error every time the sub is called.

Unable to cast object of type
'Dbasic.EnhancedControls.CEnhancedLabel' to type 'Dbasic.IText'.
Continue


Here's Sub killlabel
B4X:
Sub killlabel(y)
Control("Label" & y).text=""
End Sub


I'm a bit confused.
It worked fine before V6.80
 
Top