replacing only exact matches in script

Dr. Hawkins dochawk at gmail.com
Wed Aug 7 17:16:28 EDT 2019


On Aug 7, 2019, at 1:05 PM, Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Again, this is probably better handled with database queries.

The catch is that I’m doing this to *build* those queries (or, actually, to invoke a combination)!

the combination I mentioned would cause another value to be calculated with that formula if either pay or monthly pay changed.  That is, in the routine to update monthlypay (or pay), another handler would update this dependency

Currently I have a big ugly switch for each variable holding database commands (or usually  functions calling them) to update dependent variables.

The main table for a given debtor (client) has a few hundred lines and a half dozen columns (for string or pennies, default values for each, and a couple more).   The other table has anywhere from a couple to a couple of hundred entries with several dozen columns.

Combining debtors in a single table would be undesirable for a variety of reasons.

> But looking at your example, wouldn't it be simpler to replace "*" with space & "*" & space, and likewise with everything not a-z A-Z including cr, lf, etc? Now you have a guarantee that wholematches will work with words. 



Doing that procedurally brings me back to the same column, while manually entering like that is just asking for trouble—there are *so* may entries that I’m going to leave out a space, and *BAM*.

A shortened version of what I have is to create theTrWds
repeat for each trueword theVar in varForm

switch

case theVar is among the keys of theTrWds

case theVar is a number

case char 1 of theVar is not an alphanumeric character —but I need a valid test for this

next repeat

break

case theVar is among the keys of dinfoDtyps

put theVar & space after theTrWds

break

end switch

end repeat


repeat while word 1 of theTrWds is not empty

put word 1 of theTrWds into theVar

delete word 1 of theTrWds

switch

case theTrWds contains theVar

--it's a substring of another; skip for now

put theVar & space after theTrWds

next repeat

break

default

put replaceText(varForm,theVar,"getVal(theVar,,,dbtr)") into varForm

break

end switch

end repeat

 
— 
Richard E. Hawkins, Esq.
The Hawkins Law Firm
3430 E. Flamingo Rd.
Suite 232
Las Vegas, NV  89121
(702) 508-8462




More information about the use-livecode mailing list