Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Tue Nov 21, 2017 3:45 pm

All times are UTC - 7 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Aug 15, 2012 10:36 am 
Offline

Joined: Wed Aug 15, 2012 10:28 am
Posts: 2
I am looking at adding a version string to the user header as described in Appendix C and E of the Programmer's Reference Manual. Appendix E states that the data from the user header can be retrieved from the application with GetBinaryResource. I would like to be able to pull the version string from the header and display it to the user on screen. Do you have an example of how to access user header data from within the application?

I am using Qlarity 2.63 and a QTERM-G56.

Thanks!
-Tim


Top
 Profile  
 
PostPosted: Wed Aug 15, 2012 10:49 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Here is a brief code sample that demonstrates how to use GetBinaryResource to parse a variable initial value from the user header.

Code:
#option _SS_Lines
#option _SS_Marquee

dim VerStr as string
init VerStr := "Version 1.01"

func Startup ()
    handles MSG_INIT

    dim userHeader as string
    dim Version as string
    dim pos1, pos2 as integer
    userHeader = GetBinaryResource(bff_user_header)

    pos1 = find(userHeader, 0, -1, "VerStr=\"")
    pos2 = find(userHeader, pos1+8, -1, "\"")

    version = mid(userHeader, pos1+8, pos2-pos1-8)
    _print("The version is {" + version + "}")
    return
endfunc


Note that for this sample to work, you need to go to Tools->Settings->Compile and add
Code:
-uhi VerStr

to the Extra compiler flags box.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Wed Aug 15, 2012 10:54 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Note that in general, parsing an initial value from the user header within Qlarity isn't particularly useful -- after all you can just use the variable directly. Where it becomes more useful is for external tools to be able to look at a .bff file and extract the version information.

GetBinaryResource(bff_user_header) is more useful to the Qlarity application if you are interested in the date that the BFF was compiled.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Wed Aug 15, 2012 1:35 pm 
Offline

Joined: Wed Aug 15, 2012 10:28 am
Posts: 2
Jeremy,

Thanks for the quick response. I want to be able to choose the version number at build time. I'm actually generating the version number externally and loading it into the header via the -uhs compiler option. I was able to adapt your solution to pull out the version number. In this case, it looks like the value isn't wrapped in quotes, but starts with VerStr= and ends with a newline (\n). Is each field in the user header always expected to be terminated with a newline?

The big missing piece for me was the bff_user_header resource name. I didn't see it in the documentation anywhere. We have a utility on the system to which the handheld is attached that can load new versions of the handheld software. Having the version number in the header would allow the utility to check the version before trying to load new software.

Thanks again!
-Tim


Top
 Profile  
 
PostPosted: Thu Aug 16, 2012 6:26 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
I can see how that might not be obvious.

For reference, if you are interested: bff_user_header is briefly documented with the GetBinaryResource function. Also, if you type GetBinaryResource( in CodeView, the autocomplete help will provide bff_user_header as an option.

Also, an alternative implementation which may be more convenient for a script-based system would be to place the init VerStr line of code in a separate file and then use
Code:
#include "VersionFile.txt"
in your global code. Then you can have your script just update that file as needed.

Yes, the compiler will emit a newline between each entry in the user header. (I would recommend not putting a newline in the content of your entries to make parsing easier).

_________________
Jeremy
http://www.beijerinc.com


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