[jawsscripts] Re: String manipulation...again.

  • From: "Paul Magill" <magills@xxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Thu, 26 Aug 2010 20:20:10 +1000

Hi Mike,

Just a concept here in psuedo code, not attempting to simulate Jaws code,
except for the function names.
start
loop to step through each of the ini keys holding the words, & in sync, also
the abbreviations
if *StringContains* OneWordFromINIFile  in sText
do a *StringReplaceSubString*  with sText, the word, the abbreviation
end string contains condition
increment to the next key. see below
loop end

any tidying up
end

I have incremented INI keys for an unrelated purpose. code extract below.
The below simply records the date & time  of an event, & a list of those
start times can be brought up in a DLG list.
Hopefully it explains the principle, but the below is not directly copyable
to your situation
Note, in your situation, you could use one section name for the words, & one
for the abbreviations, or use the same key for both & use a delimiter to
seperate the word & abbreviation.
Copy of INI file first, then the code.

Regards,
Paul from Aust


[Start up section]
Counter=8
1=7:28 PM, Saturday, 21 August 2010
2=9:36 AM, Sunday, 22 August 2010
3=11:08 PM, Sunday, 22 August 2010
4=5:56 PM, Monday, 23 August 2010
5=8:54 PM, Tuesday, 24 August 2010
6=8:36 PM, Wednesday, 25 August 2010
7=10:08 PM, Wednesday, 25 August 2010
8=5:35 PM, Thursday, 26 August 2010
9=5:40 PM, Friday, 20 August 2010
10=2:24 PM, Saturday, 21 August 2010

Void Function RecordStartTimeDate ()

; records each new entry on a new key, cycling around to overwrite the nth
entry

VAR

INT StartCount,

STRING CurrentTimeDate,

STRING CountString

LET StartCount = IniReadInteger (S_StartUpSection, S_StartCount, 0,
S_StartTimeFile)

LET StartCount = StartCount + 1

IF (StartCount > C_StartMaxDays) THEN

LET StartCount = 1

EndIf

IniWriteInteger (S_StartUpSection, S_StartCount, StartCount,
S_StartTimeFile)

LET CurrentTimeDate = SysGetTime () + ", " + SysGetDate ()

LET CountString = IntToString (StartCount)

Pause ()

IniWriteString (S_StartUpSection, CountString, CurrentTimeDate,
S_StartTimeFile)

; SayString ("date recorded, " + CountString) ; for testing only

EndFunction

?



Script ShowPreviousStarts ()

VAR

INT StartCount,

INT Entries,

STRING TimeDate,

STRING DisplayList,

STRING CountString

LET Entries = 0

LET StartCount = IniReadInteger (S_StartUpSection, S_StartCount, 0,
S_StartTimeFile)

LET CountString = IntToString (StartCount)

LET TimeDate = IniReadString (S_StartUpSection, CountString, Nul,
S_StartTimeFile)

While (Entries < C_StartMaxDays) && (StringLength (TimeDate) > 3)

LET DisplayList = DisplayList + TimeDate

LET StartCount = StartCount - 1

IF (StartCount < 1) THEN

LET StartCount = C_StartMaxDays

EndIf

LET Entries = Entries + 1

LET CountString = IntToString (StartCount)

LET TimeDate = "|" + IniReadString (S_StartUpSection, CountString, Nul,
S_StartTimeFile)

EndWhile ; further entries & values to read

DlgSelectItemInList (DisplayList, "Previous start times ", False)

EndScript


----- Original Message ----- 
From: "Mike" <mike_sharp@xxxxxxxxxxxxx>


Hello all,

My next scripting project involves updating some scripts that that have been
in use for a while and that were written by a colleague who has moved on to
pastures new.
There are many things about the scripts that I do not like, one of which is
the constant updating that is required. One aspect of this relates to a text
box on the users application that is only able to accommodate a maximum of
256 characters. The script is currently setup to extract all of the notes in
this text box and replace some commonly used words with abbreviations and
then paste the text back into the application to free up some space for
extra notes when required.
The person who wrote the scripts was having to update them with new words
and abbreviations when the end user required them but I would like the user
to be able to do this without my intervention.
My first thought was to remove the words and abbreviations from the script
and place them in an ini file where the script would access them. I am
confident that I am able to provide the user with the means of either
creating a new word and abbreviation, updating a current abbreviation and
deleting abbreviations from the list using a combination of inireads,
InputBox and DLGSelectItemInList commands.
The area in which I am finding trouble with is comparing the text within the
text box with multiple key values in an ini file and replacing them with an
equivalent abbreviation.
Anybody who can advise whether an ini file is or is not the best route for
this?
If I extract text from a program and call it sText, which is the best way to
stringreplace a word that exists in sText and matches one in an ini file
with the corresponding abbreviation which also exists in an ini file?

Open to suggestions.

Regards

Mike



__________�

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

__________�

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

Other related posts: