SetMemory
Set/Create named binary storage
BOOL SetMemory( LPCSTR lpcszName, vector<byte> & vb, BOOL bSetDirty = FALSE )
TRUE if success
EX1
string OriginObject_SetMemory_Support_Ex1(LPCSTR lpcszFilename) { string str; stdioFile ff; bool bRet = ff.Open(lpcszFilename, file::modeRead); if(!bRet) { out_str("file not found!"); return str; } string strTemp; while(ff.ReadString(strTemp)) str += strTemp + "\r\n"; ff.Close(); return str; } void OriginObject_SetMemory_Ex1() { Page pg = Project.Pages(); if(!pg) return; string strFilename = GetAppPath() + "origin.ini"; string strFileContent = OriginObject_SetMemory_Support_Ex1(strFilename); vector<byte> vb; if(strFileContent.GetBytes(vb) && pg.SetMemory("Test", vb)) out_str("Saving origin.ini into page.info done"); }
Ex2
void OriginObject_Storage_Ex2(string strPageName = "Book1", string strStorageName = "SomeJunk") { Page pg = Project.Pages(strPageName); if(pg) { Tree tr; tr.Company.strVal = "ACME Corp"; pg.PutBinaryStorage(strStorageName, tr); vector<string> vsNames; pg.GetStorageNames(vsNames); for(int ii = 0; ii < vsNames.GetSize(); ii++) { printf("%d %s\n", ii, vsNames[ii]); } pg.SetMemory(strStorageName, NULL); // to set the storage memory as NULL out_str("del "+ strStorageName); pg.GetStorageNames(vsNames); for(ii = 0; ii < vsNames.GetSize(); ii++) { printf("%d %s\n", ii, vsNames[ii]); } } else printf("Not this page named %s in project\n", strPageName); }
OriginObject::GetMemory
origin.h