[jawsscripts] Re: Problem with StringToFile, Jamal's HSL

  • From: Andrew Hart <ahart@xxxxxxxxxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Fri, 23 Nov 2012 10:31:13 -0300

Ok.  I am surprised!  it's good you have a hack that solves your problem 
though, Brian.  However, the plot thickens.  I wrote the following test 
script which basically does what you did but it outputs two files, one 
using StringReplaceSubstring to remove the ASCII Null char and the other 
not using it.

Script StringToFileTest()
Var
   String s,
   String s2
Let s = "hello "
Let s = s+"world"
Let s2 = StringReplaceSubstrings(s, "\0", "")
StringToFile (s, "c:\\tmp\\test.txt")
StringToFile (s2, "c:\\tmp\\test2.txt")
If StringLength(s)==StringLength(s2) && s==s2 Then
   MessageBox("Strings are the same")
EndIf
EndScript


Comparing the two files reveals the difference Brian encountered. 
test.txt is 12 bytes in length while test2.txt is 11 bytes in length. 
However, comparing the two strings before and after the removal of Null 
chars shows that, as far as JAWS is concerned, they are equal.  The 
MessageBox on the third-last line gets displayed when the code is run. 
Note I've used the old technique for comparing that two strings are equal.

So, there's something definitely squirly going on here, but perhaps it's 
not the JAWS-COM interface that's at fault since 
StringReplaceSubstrings, a JAWS built-in function, is capable of 
removing a non-existent (from the pov of JAWS script) null char from a 
string that becomes apparent when the string is passed to a COM object. 
  If it were only a matter of JAWS incorrectly passing the string to the 
COM object, then StringReplaceSubstrings wouldn't have an affect.  It's 
rather worrisome as an issue of this kind has the potential to break 
other COM-dependent things.

Cheers,
Andrew.

On 22/11/2012 7:08 PM, Brian Hartgen wrote:
> Hi Gordon
>
> Thanks so much again for your help. I've just got home and had to try it out 
> straight away, it works a treat by the looks of it.
>
> Thanks again.
>
>
> -----Original Message-----
> From: jawsscripts-bounce@xxxxxxxxxxxxx 
> [mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Luke, Gordon
> Sent: 22 November 2012 15:56
> To: jawsscripts@xxxxxxxxxxxxx
> Subject: [jawsscripts] Re: Problem with StringToFile, Jamal's HSL
>
> Hi Brian
> It's not a space at the end of the file.  Instead it's a character 0.  Not 
> entirely sure why Jaws 14 is adding this in but I'm sure people with far 
> greater knowledge than myself can let us know.  Perhaps there's a compiler 
> directive that is required to make the string concatenation behave in a 
> similar way to earlier Jaws versions.
>
> Anyway all you need to do is to call Jamal's function and replace the 
> character 0 characters with empty strings e.g.
>
> StringToFile (StringReplaceSubstrings (temp, "\0", ""), "c:\\temp\\test.txt")
>
> Hope this helps
>
> Cheers
>
> Gordon Luke
> Senior Systems Analyst
>
> IT Services
> Capita
> PO Box 25, Craigforth, Stirling, FK9 4UE
>
> Tel (Ext) : +44 (0) 1732 42 9044
> Tel (Int) : 2319044
> Email      : Gordon.Luke@xxxxxxxxxxxx
>
> www.capita-its.co.uk
>
> Data Classification: Internal Use Only [ x] / Confidential [ ] / Commercial 
> in Confidence [ ] / Public [ ]
>
> -----Original Message-----
> From: jawsscripts-bounce@xxxxxxxxxxxxx 
> [mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Brian Hartgen
> Sent: 22 November 2012 14:41
> To: jawsscripts@xxxxxxxxxxxxx
> Subject: [jawsscripts] Problem with StringToFile, Jamal's HSL
>
> Hi
> I have a problem which is baffling me at the moment. For various projects 
> available to the community, I use Jamal's Homer Script Library. It is full of 
> useful functions and I've used it for years.
>
> However there is one function which is causing a problem. It works fine with 
> many jaws versions up to and including 13, but it does not work correctly in 
> 14 and I do need it to if anyone can please suggest a solution.
>
> The function, StringToFile, writes a string to a text file. In jaws 14, this 
> is working fine except that it leaves an extra space character at the end. 
> This can be simulated simply as follows:
>
> Assume that homer.jsb is attached via a use statement to your script.
>
> Script test700 ()
>
> saystring ("ok")
>
> var
>
> string temp
>
> let temp = "hello "
>
> let temp = temp +"goodbye"
>
> StringToFile (temp, "c:\\temp\\test.txt")
>
> ã
>
> ã
>
> EndScript
>
>
> This outputs to a text file "hello goodbye", then a space character, rather 
> than just having a clean file.
>
> Does anyone have a suggestion as to how I may erase the space character?
>
> Thank you.
>
> Brian Hartgen
>
> __________ï
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
>
>
>
>
> This email is confidential and should not be used by anyone who is not
> the original intended recipient. Prudential cannot accept liability
> for statements made which are clearly the sender's own and not made
> on behalf of the Prudential. In addition, no statement should be
> construed as giving investment advice within or outside the United
> Kingdom
>
> Prudential plc, incorporated and registered in England and Wales.
> Registered Office at Laurence Pountney Hill, London, EC4R 0HH.
> Registered number 1397169. Prudential plc is a holding company,
> subsidiaries of which are authorised and regulated by the Financial
> Services Authority (FSA)
>
> 'Prudential' is a trading name of The Prudential Assurance Company
> Limited, which is incorporated and registered in England and Wales.
> Registered Office at Laurence Pountney Hill, London, EC4R 0HH.
> Registered number 15454. Authorised and regulated by the Financial
> Services Authority. 'Prudential' is also used by other companies within
> the Prudential Group, which between them provide a range of financial
> products including life assurance, pensions, savings and investment
> products
>
> 'Prudential' is also a trading name of Prudential Distribution Limited,
> which is incorporated and registered in Scotland.  Registered Office at
> Craigforth, Stirling, FK9 4UE.  Registered number SC212640. Authorised
> and regulated by the Financial Services Authority.
>
> A list of other Prudential companies together with their registered
> statutory details can be found in 'About Prudential' on 
> http://www.prudential.co.uk/prudential-plc/aboutpru
>
> An email reply to this address may be subject to interception or
> monitoring for operational reasons or for lawful business practices.
> __________ï
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
> __________ï
>
> View the list's information and change your settings at
> http://www.freelists.org/list/jawsscripts
>
>
>


__________ï

View the list's information and change your settings at 
http://www.freelists.org/list/jawsscripts

Other related posts: