Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Thu Nov 23, 2017 11:21 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Jun 25, 2014 9:47 pm 
Offline

Joined: Fri Sep 18, 2009 10:59 pm
Posts: 19
Location: Mumbai, India.
Hello

I want to read and write into text file and check in simulation mode.
I am able to read and write on my target (Qterm A12). But I want to know, how can i do the same in Simulation.

Thanks,
Jay


Top
 Profile  
 
PostPosted: Mon Jul 07, 2014 9:00 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
You can do it exactly the same way you do on the QTERM-A12. Note that most files created during Simulation mode are temporary (they disappear when Qlarity Foundry is closed). If you want the file to be persistent you can write it to the /sim: folder.

Here is how I might handle something like that:
Code:
dim dirPrefix as string
#if _tool_sim
    init dirPrefix := "/sim:/"
#else
    init dirPrefix := "/"
#endif


I would then use dirPrefix as the prefix to any files I create or open.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Thu Jul 10, 2014 9:44 pm 
Offline

Joined: Fri Sep 18, 2009 10:59 pm
Posts: 19
Location: Mumbai, India.
Thanks Jeremy for Reply..

I want to read file in simulation mode. I have following queries:
1. In which folder (on my PC) should I keep the corresponding text file, so that I can read it in simulation mode.
2. I tried following.
I kept my text file "errFile.txt" in folder where my .qly file is present. And I tried reading using following code:
errFileFd = OpenFile("/sim:/errFile.txt", FILE_READ and FILE_TEXT)

On simulation, I found exception
Exception 247: Text file mode not allowed for the device (severity 5).


Request you to guide me further.

Thanks,
Jay


Top
 Profile  
 
PostPosted: Fri Jul 11, 2014 6:48 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Ah, I had forgotten about that. Text files are only supported on the native Qlarity file system, not on auxiliary ones. However, you probably don't want a text file at all. What Qlarity calls a text file is not straight up ASCII data like a text mode file on the PC might be. When reading and writing a text file, Qlarity will run all writes through the Str API and all reads through the Val API. This means that if you call
Code:
WriteFile(fileDesc, "HI")

Then the data written to disk will be "[72, 105]" (without the quotes). This is rarely what you want -- especially if you are interested in harvesting the file saved from Simulation View and using it elsewhere. Text mode would better be called record mode.

Normally I will just use a binary file and write whatever I want, possibly adding some sort of separator such as \n between records. When I want to read the file, I will just create a byte array that is the same length as the file and read the entire thing into the array then parse the array as needed.

If you are using Qlarity Foundry 2.63, the file will be located in <Local AppData>\Qlarity2\runtime\SimFiles folder. For me, under Windows 7 this appears at C:\Users\jeremy.richards\AppData\Local\Qlarity2\runtime\SimFiles

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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