[futurebasic] Re: [FB] String resource problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2010 : Group Archive : Group : All Groups

From: Deep <Info@...>
Date: Sun, 12 Dec 2010 14:21:43 +0000
Had a look at the runtime, specifically in "Subs DefUsr.incl" which does the
heavy lifting behind the scenes for "DEF APNDSTR". Realised that it uses "fn
apndstr" and that already performs Endian conversion for you, so the problem
is elsewhere.

Try wiping the Resource file and start again, in case it was bad data from a
prior attempt?

If it persists, post a quick working demo which creates your resource file
with the bug and can look into it further.


> From: Rich Love <carnationsoftware@...>
> Reply-To: <futurebasic@...>
> Date: Sun, 12 Dec 2010 07:03:08 -0600
> To: <futurebasic@...>
> Subject: Re: [FB] String resource problem
> 
> How do I convert the rH  handle to an Endian Conversion before doing the
> ReplaceResource?
> 
> rH = FN NewHandleClear (2)
> long if rH
> DEF APNDSTR("JoAnna",rH)
> rH = FN ReplaceResource(rH, _"STR#", _tempStrList, "tempList", gExternalResId
> )
> print "1 string resource added to resource file"
> end if
> 
> 
> Rich
> 
> 
> On Dec 12, 2010, at 6:04 AM, Deep wrote:
> 
>> 
>> The value 768 is relevant if viewing in binary or hex:
>> 
>> Binary: 0000 0011 0000 0000
>> 
>> Hex: 0x0300
>> 
>> It would appear that the quantity "3" is being written but swapped in Endian
>> byte order?
>> 
>> Your Endian conversation to read 0x0300 as 0x0003 has worked hence your app
>> reports back "3" which is the decimal interpretation of 0x0003.
>> 
>> The question is how did it get written in the first place, and whether an
>> Endian conversion is required at time of writing the resource? If you are
>> writing to the handle and saving the data, you need to convert the Endian
>> order prior to writing just as you did in reverse when reading. This way, it
>> will be physically stored for backward compatibility but retained in memory
>> in the Endian byte order of the hardware where run.
>> 
>> I suspect that this is due to writing the handle bytes directly which
>> incorporates the size in the first 16 bits but in the wrong Endian order?
>> 
>> As BrianS mentioned, using Core Foundation avoids these issues...!
>> 
>> 
>>> From: Rich Love <carnationsoftware@...>
>>> Reply-To: <futurebasic@...>
>>> Date: Sun, 12 Dec 2010 04:45:47 -0600
>>> To: <futurebasic@...>
>>> Subject: Re: [FB] String resource problem
>>> 
>>> Robert,
>>> 
>>> Your corrections to the old code make the sample app work and report the
>>> correct number of strings as 3.
>>> However, when you open the resource file with ResFool, it thinks that there
>>> are 768 strings instead of 3
>>> Is that a bug in ResFool or is FN ReplaceResource writing the resource
>>> incorrectly?
>>> 
>>> Rich
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> On Dec 11, 2010, at 10:50 PM, Robert Purves wrote:
>>> 
>>>> 
>>>> Rich Love wrote:
>>>> 
>>>>> I am having the exact same problem that Joe Lertola reported in 2008
>>>>> When writing a string to a resource file, the string count is wrong in the
>>>>> resource file.
>>>>> The sample program below, returns the correct number of strings when run
>>>>> with FB4
>>>>> But with FB5, the string count is wrong.
>>>>> 
>>>>> Robert P responded to Joe saying that FN NewHandleClear(2) would fix it
>>>>> (but
>>>>> it does not chenge the symptom for me)
>>>> 
>>>> [ugly buggy old code snipped]
>>>> 
>>>> [1] In makeStringResource():
>>>> //rH = FN NEWHANDLE (2)
>>>> rH = FN NewHandleClear( 2 ) // initialised to 0 strings
>>>> 
>>>> 
>>>> [2] Replace checkResFile() by this version in which the endian bug is
>>>> fixed:
>>>> 
>>>> local fn checkResFile
>>>> dim as Handle  rH
>>>> dim as short   theCount
>>>> rH = fn GetResource( _"STR#", _tempStrList )
>>>> long if ( rH )
>>>> theCount = fn CFSwapInt16BigToHost( rH..0% )
>>>> print "The number of strings reported is " + str$( theCount )
>>>> xelse
>>>> print  "Could not make a handle for the resource in fn checkResFile"
>>>> end if
>>>> end fn
>>>> 
>>>> 
>>>> Robert P.
>>>> 
>>>> --
>>>> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> --
>>> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>> 
>> --
>> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...
>> 
> 
> 
> Rich Love - Carnation Software
> Get 'Say it & Mail it' for iPhone
> http://www.SayitMailit.com
> 
> MacWise Terminal emulation for Macintosh
> http://www.CarnationSoftware.com
> Twitter - http://twitter.com/CarnationSW
> Email - RichLove@...
> 512 858-9234
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> --
> To unsubscribe, send ANY message to: futurebasic-unsubscribe@...