Integers, strings and arrays

stu14t

Active Member
Licensed User
Longtime User
I'm having a problem with this code :

B4X:
Public Sub Display_upDate()
       Dim NOB As String
      Dim TBTP As String
      Dim PNTP As String
      
      NOB = CStr(NumOfBlows)
      TBTP = CStr(TotBlows(TestPoint))
      PNTP = CStr(Pen(TestPoint))

   Table1.AddRow(NOB,TBTP,PNTP)
End Sub

And it's throwing an error at compilation:

Compiling code. Error
Error compiling program.
Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1}
Occurred on line: 649
Table1.AddRow(NOB,TBTP,PNTP)
Word: nob


I'm using the following code, kindly supplied by Jost aus Soest, to force the integer and the two 1 dimensional arrays to strings, so the table can take them:

B4X:
Sub CStr(i As Int) As String
  Return "" & i
End Sub

What am I missing?

Many thanks
 

stu14t

Active Member
Licensed User
Longtime User
Thanks for the reply Margret

The variable NumOfBlows is not an array it's an integer, and that's the one throwing the compilation error.

The line throwing the problem is line 649:

B4X:
Table1.AddRow(NOB,TBTP,PNTP)

The conversion to string has worked but I don't understand the String.Rank=0 and String.Rank =1. The compiler seems to dislike the way I've forced it to a string.

Compiling code. Error
Error compiling program.
Error description: Cannot cast type: {Type=String,Rank=0} to: {Type=String,Rank=1}
Occurred on line: 649
Table1.AddRow(NOB,TBTP,PNTP)
Word:nob


Can I Log it if it's a compilation error and not runtime exception?
 
Last edited:
Upvote 0

stu14t

Active Member
Licensed User
Longtime User
Jost aus Soest

Thanks for the reply and the code too

I've found the error and it was my fault. I missed some code out the line should read:

B4X:
Table1.AddRow(Array As String(NOB,TBTP,PNTP))

And not

B4X:
Table1.AddRow(NOB,TBTP,PNTP)
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…