Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Save an array ... into an array or collection
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01499709
Message ID:
01499775
Views:
49
As it happens, this is a little more detailed than I needed in this particular instance, but thank you very much (always nice to see another approach that I can learn from, even if I don't use it).

Actually, this applies to all the different responses.

>How about storing a collection of cursors. Each collection member creates a backup cursor, stores its name along with a datetime the backup was created. A collection member is able to restore the original cursor from a copy when required. I don't think I would want to deal with multiple arrays. Just a suggestion.
>
>The following two classes, rather sketchy, can form a frame for such approach. Typos are possible, written in Notepad:
>
>
>DEFINE CLASS CursorStorage As Collection
>	sourcecursorname=''
>
>PROCEDURE Init( cSourceCursorName As String )
>	THIS.sourcecursorname=m.cSourceCursorName
>
>PROCEDURE Destroy
>* clean up on exit
>	DO WHILE THIS.Count > 0
>		THIS.Remove(1)
>	ENDDO
>
>PROCEDURE AddVersion
>	LOCAL oCursorVersion
>	oCursorVersion = CREATEOBJECT('CursorVersion', THIS.sourcecursorname)
>	THIS.Add(oCursorVersion)
>
>PROCEDURE RestoreVersionByDateTime( tDateTime As DateTime )
>* scan collection until a member with the closest datetime found
>* and run its Restore method
>ENDDEFINE
>
>DEFINE CLASS CursorVersion As Relation
>	created=DATETIME()
>	cursorname=<generate a unique name for cursor, use SYS(2015), GUID etc.)
>
>PROCEDURE Init( cSourceCursorName )
>	THIS.sourcecursorname=m.cSourceCursorName
>
>	SELECT * FROM (THIS.sourcecursorname);
>	INTO CURSOR ( THIS.cursorname ) NOFILTER
>
>*PROCEDURE Restore( cTargetCursor As String )
>PROCEDURE Restore
>* check if THIS.cursorname still exists
>	SELECT * FROM (THIS.cursorname);
>	INTO CURSOR ( THIS.sourcecursorname ) NOFILTER
>
>PROCEDURE Destroy
>* clean up on exit
>	IF USED( THIS.cursorname )
>		USE IN (THIS.cursorname)
>	ENDIF
>ENDDEFINE
>
Jim Nelson
Newbury Park, CA
Previous
Reply
Map
View

Click here to load this message in the networking platform