Web Connection
Public Vars and COM
Gravatar is a globally recognized avatar based on your email address. Public Vars and COM
  Paul Nesci
  All
  Dec 14, 2020 @ 05:08am

Hey All

Wondering about the best method to handle static variables between functions when using COM? I managed to pilfer a few variables from MyApp.INI which can be referenced by "goWCServer.oConfig.cVersion" for example using the Version line.

Restoring Public Memvars into MyAppMAIN cannot be referenced in other functions. This seems only for when running a compiled EXE in COM mode.

Funny there not much info around so happy to hear other approaches. Nice to load custom variables into MyApp.INI which port to goWCServer...

Gravatar is a globally recognized avatar based on your email address. re: Public Vars and COM
  Rick Strahl
  Paul Nesci
  Dec 14, 2020 @ 01:47pm

Frankly I wouldn't use memory var persistence. That's a fool's errand... instead write out your state that you care about explicitly in an object and store that with JSON or the Config class and restore as needed. Using memvar files is unreliable as heck as you can get all sorts of other crap persisted that either can't restore or won't restore in the same way it was saved (ie. your example here).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Public Vars and COM
  Paul Nesci
  Rick Strahl
  Dec 15, 2020 @ 04:20am

Thanks Rick

So Objects can be passed around through functions right in COM. Is there a particular place you recommend (actual name) I should do this and using:

loMySiteConfig = CREATEOBJ("EMPTY")
ADDPROP(loMySiteConfig, "ATHKEY","SomeSpecialKey")
ADDPROP(loMySiteConfig, "SiteID","SomeID")

Place the code in MyAPPMain FUNCTION OnLOAD?

Regards Paul

Gravatar is a globally recognized avatar based on your email address. re: Public Vars and COM
  Rick Strahl
  Paul Nesci
  Dec 16, 2020 @ 12:23pm

Yes you can load the object in OnLoad() and either create a PUBLIC var or use the Server.oCache object with AddItem() and GetItem(), or - maybe simpler - directly attach a property with ADDPROPERTY(Server.oCache,"oData",loDataObject) or something to that effect. Either way it'll live for the lifetime of the server instance. (note in OnLoad() it'll be THIS.oCache).

+++ Rick ---

© 1996-2021