Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


How to convert Hex values in file to number or string


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-20-2008, 01:08 PM
Senior Member
 
Join Date: Apr 2007
Location: Netherlands
Posts: 102
Default How to convert Hex values in file to number or string

Hi,

In a file there are some (1 to 4) consequetive bytes that form together a hex value. That file results from another program, not a Basic4PPC program. I do not succeed to make calculations with that data.

I read the relevant part of the file, opened with cRandom, into a variable. Using SubString to isolate the bytes concerned results into a message 'The XML was improperly formatted'.

I tried several things, but no result. Am I overlooking something? What is the proper way to do that?

Harry
Reply With Quote
  #2 (permalink)  
Old 02-20-2008, 01:19 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,335
Default

Which version of Basic4ppc do you use?
'The XML was improperly formatted' is an IDE bug that was fixed in V6.00.

You should read the bytes with FileGetByte or with the BinaryFile library.
Afterwards you will need to do a small calculation to get the number value.
Something like (if the value is written in two bytes and the first byte is the lower byte):
Code:
b1 = FileReadByte(c,pos)
b2 = FileReadByte(c,pos+1)
number = b1 + 256 * b2
Reply With Quote
  #3 (permalink)  
Old 02-20-2008, 05:04 PM
Senior Member
 
Join Date: Apr 2007
Location: Netherlands
Posts: 102
Default

Erel,

Thanks for your support. I use version 6.01

Harry
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I convert a string to an integer dahljam Questions & Help Needed 4 10-12-2008 08:32 PM
Colour Values Zenerdiode Questions & Help Needed 2 05-20-2008 06:01 AM
Wrong values on GPS Roadrunner Bug Reports 1 01-31-2008 08:10 PM
Reading ini file values into a combox-list Softselect Questions & Help Needed 2 11-15-2007 04:41 AM
is a single character string a number as well? Stellaferox Questions & Help Needed 16 06-08-2007 12:01 PM


All times are GMT. The time now is 07:15 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0