B4R Question Join string + number

Mostez

Well-Known Member
Licensed User
Longtime User
Hello,
I'd like to open files for read in sequence i.e. file1.dat, file2.dat, file3.dat... etc. any ideas, got errors when trying to join string (filename) and decimal counter.

Thanks
 

Mostez

Well-Known Member
Licensed User
Longtime User
ok, but i don't want to open then at same time, i need to open them one after another
 
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User
binary files of 504 bytes each, holding bitmap of images, i will load file data to an array then display it on LCD, this procedure works very fine, but i need to send file names in sequence to display images in sequence one after another, image1.bin, imag2.bin and so on

i.e. LoadImageFile(image1.bin) 'works very fine and display image ok

B4X:
private Sub LoadImageFile (fileName As String)
    Dim Buffer (504) As Byte
    If Sd.OpenRead(fileName) Then
            Sd.Stream .ReadBytes(Buffer,0,503)
            Sd.OpenRead("") 'some dirty dots appear at the end, that's the only way worked to removed them
            Sd.Close
        WriteByte(0x80, 0)
        WriteByte(0x40, 0)
        WriteByte(0x80, 0)
        Dim testbyte As Byte
        For i=0 To 503
            testbyte = Buffer(i)
            WriteByte(testbyte, 1)
        Next    
    End If
End Sub

but i want to make
B4X:
For M = 0 To 10
        Dim filename As String
        filename = JoinStrings("image",m,".bin")
      LoadImageFile(filename)
    Next

I get this error
Cannot cast type: {Type=StringLiteral,Rank=0, RemoteObject=True} to: {Type=String,Rank=1, RemoteObject=True}
 
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User
I did not guess the code and error, i wrote the code already and got that error message, then I posted that question because i could not handle it, may be not posting the code at first was a mistake.

Thanks for help
 
Upvote 0

Similar Threads

Top