[jawsscripts] Re: script help

  • From: "Paul Magill" <magills@xxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Wed, 3 Jun 2009 18:03:46 +1000

Hi Haden,

This scripting task is not nearly as straightforward as it first might seem, 
so I would recommend the skim reading method already suggested.

Indeed, until it was recommended, I was unaware of skim reading's 
potential, & thank the Count for pointing it out.

Now a little about the problem of scripting the task.

The first parameter of the StringContains function is a string that already 
contains all the text to be searched. Namely, you need to have loaded the 
text from the file into a string variable.  That can be done, but is a bit 
involved to automate.

You could highlight the text in the file & copy it to the clipboard, then 
use the GetTextFromClipboard  function to place it in the string.

The other issue is that StringContains only locates the first instance of 
the text you are searching for. It is not intended, or able to count the 
instances.

I am not aware of a function that will do that counting for you.

There a couple of ways that such a function may be constructed, but they 
would be somewhat involved.

Regards,
Paul from Aust

----- Original Message ----- 
From: "Haden Pike" <haden.pike@xxxxxxxxx>


Hi list. Sorry for the unhelpful subject line but I couldn't think of a good 
subject line. Anyway, I am having some trouble with a script. The script is 
below and my problems follows.
Script NumberOfStringOccurances ()
; calculates the number of occurances for the given string

var

String SOccuranceString,

Int INumber

let INumber = 0

InputBox ("Find number of occurances of what:", "String Occurance", 
SOccuranceString)

If (StringContains (SOccuranceString )) then

let INumber = INumber+1

EndIf

EndScript

Now, as you know string contains requires 2 parameters. The first is the one 
I don't know about. How can I make it search the entire file. Is there 
another function I should use instead. This script, as you probably figured 
out from the comment and the title of the script, displays the number of 
occurances of a string in a file. Thanks for any help.


Haden Pike

__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

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

Other related posts: