Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Expand existing array and insert into middle of array?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Expand existing array and insert into middle of array?
Divers
Thread ID:
00554257
Message ID:
00554257
Vues:
56
Here's what I am trying to do, but not quite sure how to go about it. I put a memo field into an array. No problem. I want to insert a new line into the memo field about half-way down, but now the memo field is in an array with rows in the array representing lines in the memo field.

I want to insert a line in the memo field about half-way down from the top of the memo field to the bottom of the memo field which is now in an array. So I want to insert a new row in the array about half-way down from the top of the array to the bottom of the array.

I can't add my line to the end of the array because it is the Properties memo field that contains a Forms Properties such as ControlSource=,Height=, HelpContextID=,etc.

Here's the part of my code that I am modifying to do this. See the part where I added all the comments in the middle. That is where I am trying to do this:
* Find matching field name in Data Dictionary
SET EXACT OFF
seekid = ALLT(formdbfs.db_name)+UPPER(ALLT(CtrlSrce))
USE datadict IN 0 SHARED
SELECT datadict
SET ORDER TO db_field
SEEK seekid
IF FOUND()
	* Find HelpContextID and replace its value
	STORE "HelpContextID =" TO gcString3
	SELECT form_file
	ALINES(WorkArray,properties)
	SET EXACT OFF
	IF ASCAN(WorkArray,gcString3) > 0
		gnPos = ASCAN(WorkArray,gcString3)
		HlpCntxtID = WorkArray(gnPos)
		HelpCntxtID = SUBSTR(HlpCntxtID,17,Len(HlpCntxtID)-16)
		WorkArray(gnPos) = "HelpContextID = " + ALLT(STR(datadict.help_num))
	ELSE
		* Did not find HelpContextID in array.
		* Need to insert HelpContextID row after Height row in array.
		* Expand array by one row.
		* Insert HelpContextID row.
		* Move rest of array rows down one.
		STORE "Height =" TO gcString3
		IF ASCAN(WorkArray,gcString3) > 0
			gnPos = ASCAN(WorkArray,gcString3)
			Ht = WorkArray(gnPos)
			***** Not sure what code goes here to make above   comments happen *****
			WorkArray(gnPos) = "HelpContextID = " + ALLT(STR(datadict.help_num))	
		ENDIF
	ENDIF
	FOR i = 1 TO ALEN(WorkArray,1)
		lcProperties = lcProperties + WorkArray(i)+CHR(13)+CHR(10)
	ENDFOR
	IF INT(VAL(HelpCntxtID)) <> datadict.help_num
		IF nAnswer2 = 6
			REPLACE form_file.properties WITH lcProperties
		ELSE
			nAnswer = MESSAGEBOX("Form field HelpContextID=" + ALLT(HelpCntxtID) + ;
				" does not match Data Dictionary Help Number " + ALLT(STR(datadict.help_num)) + ;
				". Do you want to replace it?",4+32+256,"Data Dictionary")
			IF nAnswer = 6
				REPLACE form_file.properties WITH lcProperties
			ENDIF
			IF nAnswer2 = 0
				nAnswer2 = MESSAGEBOX("Do you want to replace all HelpContextIDs from Data Dictionary?",4+32+256,"Data Dictionary")
			ENDIF
		ENDIF
	ENDIF
ELSE
	MESSAGEBOX("Field " + UPPER(ALLT(CtrlSrce)) + " not found in Data Dictionary. " + ;
		"You may add the field later using the Form to Data Dictionary form.",64,"Data Dictionary")
ENDIF
I can find where to insert my line into the array, but not sure about shuffling the other array entries down one from the insertion point and how to find the end of the array without going past it causing an error. Your help is appreciated. Thanks.
Steve Kramer
Kramer & Kramer Design
"Home of Go Cartoons"
Web Site: www.stephenkramer.com
Would you believe Far Side Lite?
More than 270 original cartoons.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform