Information générale
Catégorie:
Codage, syntaxe et commandes
Ben,
I am passing an array by reference to a method which strips a comma delimted string of random length into its component parts and adding each one to the array.
This method has been in use for over 6 months as a component of a number of systems.
The problem in the latest system is that each DIMENSION of the passed array resets all the existing elements to .F.
I reproduce the same effect from the command line. Below is an example of what i am doing, I would be grateful if anyone could let me know if they have come across this or are aware of any environment setting that would cause a re-DIMENSION to clear an array's elements.
Many thanks in advance,
Ben Sugden
I.e.
*-- Method passing Array
LOCAL lcString
lcString = "Element1, Element2, "... ", Elementn"
DIMENSION laContents[1]
THIS.PopulateArray(@laContents, lcString)
*-- THIS.PopulateArray Method, receives array
LPARAMETERS taReferredArray, tcString
*-- Code to strip string and loop for each section
FOR lnCount = 1 TO lnSections
DIMENSION taReferredArray[lnCount] && Here is where the issue occurs
taReferredArray = lcStrippedValue
ENDFOR
Every entry into this method will redimenson the array starting at 1.
DIMENSION taReferredArray[lnCount] && lnCount starts at 1
Then lcStrippedValue is only being loaded into the first element
taReferredArray = lcStrippedValue
instead of,
taReferredArray[ALEN(taReferredArray,1)] = lcStrippedValue
Hope this helps,
Phil
Précédent
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