1. Claudius Sailer
  2. Valentina Database ADK
  3. Mittwoch, November 08 2017, 08:28 PM
  4.  Abonnieren via E-Mail
I use following coding for initializing my database in my Tojo Project.


If PrefDic.value("DatabaseCache")>1 then
Valentina.Init(PrefDic.value("DatabaseCache")*1024*1024,VC,"")
else
Valentina.Init(DatabaseMinimumCache*1024*1024,VC,"")
end if

Valentina.SetExtensions("", "", "", "ind")


this is called only once a time when App (OpenDocument Event in App) is started. But it seems this is called more often. I know I have to check this in my code. My question is an other.

How can I check whether valentina is already initialized and check this before the code is passed again and throws the error?

Can I check valentina=NIL or something else?

Thanks for help
Anhänge
Kommentar
There are no comments made yet.
Claudius Sailer Akzeptierte Antwort
this is now my new code....
thanks for help :-)


if Valentina.CacheSize=0 then //ist der wert nicht 0, dann ist Valentina bereits initialisiert und es würde zu einer Fehlermeldung kommen

If PrefDic.value("DatabaseCache")>1 then
Valentina.Init(PrefDic.value("DatabaseCache")*1024*1024,VC,"")
else
Valentina.Init(DatabaseMinimumCache*1024*1024,VC,"")
end if

Valentina.SetExtensions("", "", "", "ind")

if CheckLeer(VC) then
t=new TestTimer
t.period=540000
t.mode=2
end if

if Valentina.CacheSize=0 then
MsgBox "Valentina konnte nicht initialisiert werden !!! Error: " + Str(Err)
end if

end if
Kommentar
There are no comments made yet.
Ruslan Zasukhin Akzeptierte Antwort
Ivan,

let me correct you. Wiki page

**Note:** You should not call this method second time before Valentina.ShutDown(). Otherwise you will get an error. This is like with file.open() file.close() methods. You can use Valentina.CacheSize property to check if Valentina is initialized already.


For C++ devlopers: it needs to use Valentina.Init(0) to get the current cache size.
Kommentar
There are no comments made yet.
Ivan Smahin Akzeptierte Antwort
Hi Claudius,

Currently, there is no such a feature. The only way is to catch an error on double init attempt.
Something like this one:


try
If PrefDic.value("DatabaseCache")>1 then
Valentina.Init(PrefDic.value("DatabaseCache")*1024*1024,VC,"")
else
Valentina.Init(DatabaseMinimumCache*1024*1024,VC,"")
end if

Valentina.SetExtensions("", "", "", "ind")
Exception err1 as VException
if err1.ErrorNumber = 603396 then
' Silently ignore double Init attempt.
else
Raise err1
end if
end
Kommentar
There are no comments made yet.
Claudius Sailer Akzeptierte Antwort
I use following coding for initializing my database in my Xojo Project.


If PrefDic.value("DatabaseCache")>1 then
Valentina.Init(PrefDic.value("DatabaseCache")*1024*1024,VC,"")
else
Valentina.Init(DatabaseMinimumCache*1024*1024,VC,"")
end if

Valentina.SetExtensions("", "", "", "ind")


this is called only once a time when App (OpenDocument Event in App) is started. But it seems this is called more often. I know I have to check this in my code. My question is an other.

How can I check whether valentina is already initialized and check this before the code is passed again and throws the error?

Can I check valentina=NIL or something else?

Thanks for help
Anhänge
Kommentar
There are no comments made yet.
  • Seite :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.