Information générale
Titre:
GATHER FROM ArrayName MEMO bug
Problem:
When gathering the contents of an array to a memo field using the GATHER FROM ArrayName MEMO command, only the first row of the array is gathered.
The program below illustrates the problem. I searched the UT for the last couple years and did not find a similar report. Has anyone else experienced this problem?
Any insight into this matter is much appreciated.
*----------------------------------------------------------------
* Program: GATHERBUGCHECK.PRG
* Author: Paul K. Mender
*----------------------- Usage Section --------------------------
*) Description:
*) Demonstrates a bug in GATHER FROM array.
* Parameters:
* None
*$ Usage:
*$ DO Gatherbugcheck
* Returns:
*--------------------- Maintenance Section ----------------------
* Notes:
*
* Change Log:
* CREATED August 3, 2000 11:11:51 - PKM
******************************************************************
#DEFINE cBUGCHECK_DBF BugCheck.DBF
#DEFINE ccBUGCHECK_DBF "BugCheck.DBF"
#DEFINE ccBUGCHECK_ALIAS "BugCheck"
*-- Define the array for ALINES() as public. (This works?)
RELEASE gaLines
PUBLIC ARRAY gaLines[1]
*-- Define the array for ALINES() as local. (This doesn't work?)
LOCAL ARRAY laLines[1]
LOCAL ;
lcAlias,;
lcMemoContents,;
lcMsg,;
lcSetSafety,;
liI,;
lnLocalLines,;
lnMemoLines,;
lnNewMemoLines,;
lnPublicLines
lcSetSafety = SET("SAFETY")
SET SAFETY OFF
lcAlias = ccBUGCHECK_ALIAS
IF USED(lcAlias)
USE IN &lcAlias
ENDIF
IF FILE(ccBUGCHECK_DBF)
DELETE FILE ccBUGCHECK_DBG
ENDIF
CREATE TABLE cBUGCHECK_DBF (mSomeMemo M)
USE cBUGCHECK_DBF ALIAS &lcAlias EXCLUSIVE
IF USED(ccBUGCHECK_ALIAS)
SELECT (lcAlias)
ZAP
APPEND BLANK
*-- Populate the mSomeMemo field
lnMemoLines = 10 && some arbitrary number of lines
lcMemoContents = ""
FOR lii = 1 TO lnMemoLines
lcMemoContents = lcMemoContents;
+"Memo line "+ALLTRIM(STR(liI))+CHR(13)
ENDFOR &&* lii = 1 TO 10
REPLACE NEXT 1 mSomeMemo WITH lcMemoContents
*-- Use the public array.
lnPublicLines = ALINES(gaLines,mSomeMemo,.T.)
*-- Use the local array.
lnLocalLines = ALINES(laLines,mSomeMemo,.T.)
*-- I originally thought that this was the
*-- cause of the problem. - PKM
IF lnPublicLines<>lnLocalLines
lcMsg = "ALINES returned different number of lines."
= MESSAGEBOX(lcMsg+CHR(13);
+"Local Array: "+ALLTRIM(STR(lnLocalLines));
+" Public Array: "+ALLTRIM(STR(lnPublicLines));
)
ENDIF
IF lnMemoLines<>lnLocalLines
lcMsg = "LOCAL ALINES returned different number of lines."
= MESSAGEBOX(lcMsg+CHR(13);
+"Local Array: "+ALLTRIM(STR(lnLocalLines));
+" memo lines: "+ALLTRIM(STR(lnMemoLines));
)
ENDIF
*-- ... replace the contents of the memo field
*-- from the local array.
GATHER FIELDS mSomeMemo FROM laLines MEMO
MODIFY MEMO mSomeMemo NOWAIT NOEDIT
lnNewMemoLines = ALINES(laNewLines,mSomeMemo,.T.)
IF lnNewMemoLines <> lnMemoLines
= MESSAGEBOX("Error! Memo lines were not completely restored."+CHR(13);
+"("+ALLTRIM(STR(lnNewMemoLines))+ " versus ";
+ ALLTRIM(STR(lnMemoLines)+")"))
ENDIF
USE IN &lcAlias
ENDIF
SET SAFETY &lcSetSafety
RETURN
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement