Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sun Nov 19, 2017 5:34 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: string data type related
PostPosted: Tue Feb 09, 2010 6:38 am 
Offline

Joined: Fri Sep 18, 2009 10:59 pm
Posts: 19
Location: Mumbai, India.
Dear sir,
I am using Qlarity Foundry 2.50 to code the application for QTERM-G75. I am transferring a 6 KB file using FTP to the falsh of the QTERM-G75. Then I am reading the file using ReadFile() API into a string.

What have I observed is that approx. 4 KB of data only gets copied to the string variable. I also tried using a byte array and redim() API to have around 7000 bytes of size. Then also the same problem occurs. How to get around this limitation? Or what is that I am doing wrong?

Code:
    dim fileContents as string
    errFileFd = OpenFile("/errFile.txt", FILE_READ and FILE_TEXT)
    ReadFile(errFileFd, fileContents)
    CloseFile(errFileFd)
    label1.value = fileContents


I also tried:

Code:
    dim fileContents[] as byte
    errFileFd = OpenFile("/errFile.txt", FILE_READ and FILE_TEXT)
    redim(fileContents, 10000)
    ReadFile(errFileFd, fileContents)
    CloseFile(errFileFd)
    label1.value = fileContents


Both the ways resulted in only having 4 KB in fileContents variable.

Please help.

Thank you.

- Jay


Top
 Profile  
 
PostPosted: Tue Feb 09, 2010 8:05 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Try this:

Code:
func test()
    dim data[] as byte
    dim desc as filedesc
    dim leng as integer

    desc = OpenFile("MyFile.txt", FILE_READ AND FILE_BINARY)
    SetFilePos(desc, -1, true)
    leng = GetFilePos(desc)
    SetFilePos(desc, 0, true)
    redim(data, leng)
    ReadFile(desc, data)
endfunc


The key understanding is that FILE_TEXT is something of a misnomer in Qlarity, and principally supported for legacy support. FILE_TEXT would be more accurately named FILE_FIELD -- data is saved to the file in fields. However, Qlarity can really only properly read Qlarity files created with FILE_TEXT that way.

Even if your file is a text file, you probably want to transfer it to the G75 using FTP's binary format and read the file with Qlarity's FILE_BINARY mode.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group