Getting a property string
1: NUMBER nvBufferLen;
2: STRING svInstallDir;
3: MsiGetProperty(hMSI, "INSTALLDIR", svInstallDir, nvBufferLen);
Where:
hMSI = handle of the MSI (gets automatically passed into functions)
INSTALLDIR = The name of the property to get
svInstallDir = The variable in which to store the returned property value
nvBufferLen = The length of the buffer, often set to 255.
Setting a property string
1: MsiSetProperty(hMSI, "INSTALLDIR", "C:\Program Files\InstallationDirectory");
hMSI = handle of the MSI (gets automatically passed into functions)
INSTALLDIR = The name of the property to set
Value = The value of the property to set to
Converting a number to string and vice versa
1: number nTemp;
2: string svTemp;
3: nTemp = 25;
4:
5: NumToStr(svTemp, nTemp); // 25 -> "25"
6: StrToNum(nTemp, svTemp); // "25" -> 25
String comparison
1: if (StrCompare("String A", "String B") == 0) then
2: // do something here
3: endif;
String concatenation
1: STRING svTemp;
2: Sprintf(svTemp,
3: "A string taking two parameters %s %s",
4: "Parameter 1", "Parameter 2");
String Trim(…) (Extracted from http://community.installshield.com/showthread.php?t=24423)
1: function Trim(aString)
2: BOOL done;
3: NUMBER startIndex;
4: NUMBER endIndex;
5: NUMBER aByte;
6: begin
7: startIndex = 0;
8: endIndex = StrLength( aString ) - 1;
9: done = ( startIndex > endIndex );
10: while ( !done )
11: GetByte( aByte, aString, startIndex );
12: if ( aByte = ASCII_SPACE ) then
13: startIndex = startIndex + 1;
14: done = ( startIndex > endIndex );
15: else
16: done = TRUE;
17: endif;
18: endwhile;
19: done = ( startIndex > endIndex );
20:
21: while ( !done )
22: GetByte( aByte, aString, endIndex );
23: if ( aByte = ASCII_SPACE ) then
24: endIndex = endIndex - 1;
25: done = ( startIndex > endIndex );
26: else
27: done = TRUE;
28: endif;
29: endwhile;
30:
31: if ( startIndex > endIndex ) then
32: aString = "";
33: else
34: StrSub( aString, aString, startIndex, endIndex - startIndex + 1 );
35: endif;
36: return 0;
37: end;
Reading XML using MS XML DOM 6 (Inspired by http://community.installshield.com/showthread.php?t=101600&page=2)
1: OBJECT oDoc, oNode, oNodeList;
2: NUMBER nvBufferLen, nTemp;
3: STRING svXPathQuery, svValue, svTemp, svMessage, svError, svLine, svLinePos;
4:
5: set oDoc = CreateObject("Msxml2.DOMDocument.6.0");
6: if (IsObject(oDoc) = FALSE) then
7: MessageBox("MSXML DOM-Document Connection Failed", 0);
8: return -1;
9: endif;
10:
11: oDoc.async = FALSE;
12: oDoc.setProperty("SelectionLanguage", "XPath");
13: oDoc.load( svInstallDir ^ UI_APP_CONFIG );
14:
15: if ( oDoc.parseError.errorCode != 0 ) then
16: NumToStr ( svError , oDoc.parseError.errorCode );
17: NumToStr ( svLine , oDoc.parseError.line );
18: NumToStr ( svLinePos , oDoc.parseError.linepos );
19: MessageBox ( "The XML File did not load correctly.\n" +
20: "Error Code: " + svError + "\n" +
21: "Error Line: " + svLine + "\n" +
22: "Error Line Position: " + svLinePos + "\n" +
23: oDoc.parseError.reason , 0 );
24: else
25: svXPathQuery = "//XPathQuery";
26:
27: try
28: set oNodeList = objDOMDOC.selectNodes( strXPathQuery );
29: catch
30: nTemp = Err.Number;
31: NumToStr(svTemp, nTemp);
32: MessageBox("Error while selecting " + strXPathQuery + " (Error + " + svTemp + ")", 0);
33: endcatch;
34:
35: if (oNodeList.length == 0) then
36: MessageBox( "No " + strXPathQuery + " elements found.", 0 );
37: else
38: for i = 0 to ( oNodeList.length - 1 );
39: set oNode = oNodeList.nextNode;
40: try
41: svValue= oNode.text;
42: //svValue = oNode.attributes.getNamedItem( strAttributeName ).value; // to get attribute value
43: catch
44: MessageBox("No value found for " + strXPathQuery, 0);
45: endcatch;
46: endfor;
47: endif;
48: endif;
Thanks to RUSKIN DANTRA!! Here I got the function and their usage! I think installAware is better then Instalshield.
ReplyDelete