Jimmy!
One of the messages you mentioned that in your databases you can use arrays as values of memo fields. Moreover, the arrays can be different numbers of elements and different element values.
Could you give code snippets:
- how to create a database;
- how to assign a memo field to a given record the value of the array;
- on the contrary, to assign to the array the value of the memo field.
Thank you
A database in which memo fields are arrays
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
Re: A database in which memo fields are arrays
you can use Var2Bin() to store a Array into Memo when using FOXDBE ( *.FPT)Eugene Lutsenko wrote:One of the messages you mentioned that in your databases you can use arrays as values of memo fields. Moreover, the arrays can be different numbers of elements and different element values.
Array can have Type "C","N","D","L" to restore it with Bin2Var() from DBF.
this Sample save/load "Points" and "Triangles" but not "Ribs" (yet)
Code: Select all
METHOD DemoDlg:SavePoints()
...
IF .NOT. FILE("TRIMEMO.DBF")
CRE_TRIPLEMEMO("TRIMEMO.DBF")
ENDIF
USE TRIMEMO.DBF EXCLUSIVE VIA "FOXCDX"
ZAP // i use 1 Record only
APPEND BLANK
REPLACE TRIMEMO->POINTS WITH Var2Bin(aPoints)
REPLACE TRIMEMO->TRIANGLE WITH Var2Bin(aTriangles)
// not used yet
// REPLACE TRIMEMO->RIBS WITH Var2Bin(aRibs)
CLOSE TRIMEMO
---
METHOD DemoDlg:GenPoints(lNew)
IF FILE("TRIMEMO.DBF")
USE TRIMEMO.DBF EXCLUSIVE VIA "FOXCDX"
::points := Bin2Var(TRIMEMO->POINTS )
::Triangles := Bin2Var(TRIMEMO->TRIANGLE)
::pointsCount := LEN(::points)
::TrianglesCount := LEN(::Triangles)
CLOSE
FOR i := 1 TO ::PointsCount
mX := ::points[i][1]
mY := ::points[i][2]
nColor := ::points[i][4]
::Circle(mX,mY,3,nColor,,.T.)
NEXT
ENDIF
---
FUNCTION CRE_TRIPLEMEMO(datei,alias,id)
LOCAL p,field_list:={}
IF !FILE(datei)
AADD(field_list,{"NUM" ,"N", 5,0})
AADD(field_list,{"DESC" ,"C",100,0})
AADD(field_list,{"POINTS" ,"V", 8,0}) // binar Memo
AADD(field_list,{"RIBS" ,"V", 8,0})
AADD(field_list,{"TRIANGLE","V", 8,0})
DBCREATE(datei,field_list,"FOXCDX") // NEED *.FPT Memo
ENDIF
RETURN(.t.)
greetings by OHR
Jimmy
Jimmy
Re: A database in which memo fields are arrays
Using Var2Bin() or DC_Ar2Str() will convert any array to a string which can then be saved in a memo field.
Converting the string back to an array is accomplished via Bin2Var() or DC_Str2Ar().
Alaska software uses this technique for CXP session management. All session data is saved to a foxcdx database in a memo field.
This also includes persistent objects. It works very well. The more I use and work with CXP the more I am impressed with Steffen's vision for this most valuable new feature of Xbase++ 2.0.
Converting the string back to an array is accomplished via Bin2Var() or DC_Str2Ar().
Alaska software uses this technique for CXP session management. All session data is saved to a foxcdx database in a memo field.
This also includes persistent objects. It works very well. The more I use and work with CXP the more I am impressed with Steffen's vision for this most valuable new feature of Xbase++ 2.0.
The eXpress train is coming - and it has more cars.