Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing common variables from multiple instances of OLE
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Accessing common variables from multiple instances of OLE
Divers
Thread ID:
00550522
Message ID:
00550522
Vues:
60
I am using VFP7. I have the following 2 OLEPUBLIC classes which work when compiled independently but not in the same .EXE file. I was wondering if someone knows how to do this. This is the code in a file called myApp.Prg

define class Common as custom olePublic
function init()
if type('global')='U'
public global
global=0
endif
global=global+1
endfunc
endDefine

define class Main as custom olePublic
common=.null.
function Init()
this.common=creatObject('myApp.Common')
wait window str(this.common.global) && this only works in VFP7
endfunc
endDefine


This code supposed to keep track how many instances of Main exist in a global variable which is in Common and accessible by all instances. The test is as follows:

xx=createObject('myApp.Main')
yy=createObject('myApp.Main')

? yy.common.global

This should yield a 2


Common is defined as Multiple Use and Main is defined as Single Use Instancing in the Project Info. Main must be Single Use for other reasons.

When compiled as two sepearte projects as VFP .EXE servers, this works well and global gets incremented. However when compiled as one file, this does not work even though Common is Multi Use.

Does anyone know why? I know this may be a little esoteric stuff. I don't want to create two seperate .EXEs OLE servers if I can help it.

Thanks

Costas
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform