Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Abreviation function
Message
De
24/06/1998 17:22:19
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Abreviation function
Divers
Thread ID:
00111383
Message ID:
00111383
Vues:
40
This is a function that will substitute abreviations for long substrings. I am curious about any observations you may have about the technique. Also, does anyone know how you would do the same in VB or Access?
* Function:  Abreviate
*
* Assumes:  table called Abrev with columns: long, short
*
* Example:  update tablename set tablename.fieldname =
*           abreviate(tablename.fieldname)

function abreviate (tcInputString)

local lcWorkString, lcWord, lcResultString, i, lcSetAnsi, ;
      lnSetMemoWidth

local array laResults[1]

lcWorkString = strtran(tcInputString, " ", chr(13))
lcResultString = ""

* The number of lines in a memo field is determined by the current value of SET MEMOWIDTH.

lnSetMemoWidth = set("MemoWidth")
set MemoWidth to 80

lcSetAnsi = set("ANSI")
set ANSI on

for i = 1 to memlines(lcWorkString)

	lcWord = mline(lcWorkString, i)

	select Abrev.Short ;
		from Abrev ;
		where Abrev.Long = lcWord ;
		into array laResults
		
	if _tally > 0
		lcResultString = lcResultString + laResults[1] + " "
	else
		lcResultString = lcResultString + lcWord + " "
	endif
	
endfor

set ANSI &lcSetAnsi
set MemoWidth to lnSetMemoWidth
		
return lcResultString
Répondre
Fil
Voir

Click here to load this message in the networking platform