cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ewgoforth
Level 4

Problem reading a property, immediately after setting

Hello,

I have a snippet of code similar to the following:



#define PROP_MY_PROPERTY "MyProperty"

function NUMBER MyFunction()
STRING strThisProperty;
STRING strThisPropertyProp;
begin
nSize = 256;
dialogName = "MyFunction";

nReturn = EzDefineDialog(dialogName, ISUSER, dialogName, 0);

if(nReturn = DLG_ERR) then
MessageBox("error on exDefineDialog MyFunction", INFORMATION);
endif;

bDone = FALSE;
while (!bDone)
nControl = WaitOnDialog(dialogName);
switch (nControl)
case MY_BUTTON_NEXT:

CtrlGetText(dialogName, CONTROL_NAME, strThisProperty); //Assign the control to the variable

MessageBox("In MyFunction.rul, strThisProperty = " + strThisProperty, INFORMATION);

strThisPropertyProp = "test";

MsiSetProperty(ISMSI_HANDLE, PROP_MY_PROPERTY, strThisProperty); //Assign the variable to the property

MsiGetProperty(ISMSI_HANDLE, PROP_MY_PROPERTY, strThisPropertyProp, nSize); //Assign the property to the variable
MessageBox("In MyFunction.rul, strThisPropertyProp = " + strThisPropertyProp, INFORMATION);

nReturn = MY_BUTTON_NEXT;
bDone = TRUE;
case DLG_INIT:
//Stuff that gets initialized

MsiGetProperty(ISMSI_HANDLE, PROP_MY_PROPERTY, strThisProperty, nSize); //Assign the property to the variable

CtrlSetText(dialogName, CONTROL_NAME, strThisProperty); //Assign the variable to the control

// ...cases for other controls...
endswitch;
endwhile;

EndDialog(dialogName);
ReleaseDialog(dialogName);

return nReturn;


end;



If I enter "Hello" in the CONTROL_NAME (which is an edit field). I see a message box that displays "Hello", followed by one that says "test".

What's strange is that Myfunction is called by MyParentFuction, which in turn is called by MyGrandParentFunction. I have code similar to the following in MyGrandParentFunction:


MsiGetProperty(ISMSI_HANDLE, PROP_MY_PROPERTY, strThisProperty, nSize); //Assign the property to the variable
MessageBox("In MyGrandparent.rul, strThisProperty = " + strThisProperty, INFORMATION);



And I see a messagebox that displays "Hello" there. It appears there might be a race condition or something like that going on, such that the property isn't set yet by the time I'm reading it in MyFunction().

At the end of the day, I need to read "MyProperty" in MyGrandParent, so this will work for me, but I'd like to understand why I can't seem to read the property in MyFunction().

-Eric
Labels (1)
0 Kudos
(1) Reply
Roman1
Level 9

Hello,

please regard this code:

nSize=255;
MsiGetProperty(ISMSI_HANDLE, PROP_MY_PROPERTY, strThisProperty, nSize);

You have to set nSize to value > 0.

Regards
0 Kudos