ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Miscellaneous WINDEV functions
  • Example for the ComponentInfo function
ComponentInfo (Example)
Example for the ComponentInfo function
The following example is used to list the patches used by an application.
// Create an array of patches
// used to store information about the patches found
strPatch is Structure
sName is string
nVersion is int
END
arrPatch is array of 0 strPatch
sInfoTakenIntoAccountPatch is string
 
// Full name of the element that accepts the patches
// whose patch information is requested.
// This element can be:
// - A WINDEV executable (.EXE)
// - A WINDEV library (.WDL)
// - A WINDEV component (.WDK)
sFullNamePatchableElement is string
 
// In this example, the "current" executable is used
// Test if test mode?
IF InTestMode() = True THEN
// In test mode: Name of the executable that has the name of the project in the EXE directory
sFullNamePatchableElement = fExeDir() + "\" + ProjectInfo(piProjectName) + ".exe"
ELSE
// In standard mode: Name of the executable
sFullNamePatchableElement = ExeInfo(exeName)
END
 
// Confirm the element by selection
sFullNamePatchableElement = fSelect(sFullNamePatchableElement, ...
"Select the element for which you want to know " + ...
"the patch information", ...
"WINDEV exe, library, component" + TAB + "*.exe;*.wd" + CR + ...
"All files (*.*)" + TAB + "*.*", "exe;*.wdl;*.wdk", fselOpen + fselExist)
// Cancelation?
IF sFullNamePatchableElement = "" THEN RETURN
 
nVersionInAccountPatch is int
WHEN EXCEPTION IN
nVersionInAccountPatch = ComponentInfo("", ciPatchNumber, sFullNamePatchableElement)
DO
Error("Unable to retrieve the version information." + ...
"If it is an executable with an external library," + ...
" you must specify " + ...
"the name of the library. Error details: ", ExceptionInfo())
RETURN
END
sInfoTakenIntoAccountPatch += [CR]+ ...
StringBuild("<%1> will take into account the patches" + ...
"found in version %2 or later.", ...
fExtractPath(sFullNamePatchableElement, ...
fFileName + fExtension), nVersionIntoAccountPatch)
 
// List of patches
sListPatch is string
sAPatch is string
// The patches have the name of the executable (or library or component)
// with a WDL extension and an "external" version number
sListPatch = fListFile(fExtractPath(sFullNamePatchableElement, ...
fFileName + fDrive + fDirectory) + ".WDL.*", frNotRecursive)
stAPatch is strPatch
// Browse the patch files found
FOR EACH STRING sAPatch OF sListPatch SEPARATED BY CR
// If it is not the element itself
IF NOT sAPatch ~= sFullNamePatchableElement THEN
// Retrieve the name
stAPatch:sName = fExtractPath(sAPatch, fFileName + fExtension)
// Retrieve the "internal" version of the patch found
WHEN EXCEPTION IN
stAPatch:nVersion = ComponentInfo("", ciPatchNumber, sAPatch)
DO
stAPatch:nVersion = 0
Trace("Cannot retrieve " + ...
"the version information of the patch <" + ...
sAPatch + ">. Error details:", ExceptionInfo())
END
// Add into the array of patches
ArrayAdd(arrPatch, stAPatch)
END
END
 
sInfoTakenIntoAccountPatch += [CR] + ...
"Let's see the list of patches found organized in the order" + ...
" in which they are taken into account:"
// Sort the patches by "internal" version number in descending order
// because the patches with the greater numbers are taken in priority
ArraySort(arrPatch, asMember, "-nVersion")
FOR EACH ELEMENT stAPatch OF arrPatch
// Patch taken into account?
IF stAPatch:nVersion >= nVersionInAccountPatch THEN
// Yes
sInfoTakenIntoAccountPatch += [CR] + ...
StringBuild("<%1> patch, version %2", ...
stAPatch:sName, stAPatch:nVersion)
ELSE
// No
sInfoTakenIntoAccountPatch += [CR] + ...
StringBuild("<%1> patch NOT TAKEN INTO ACCOUNT" + ...
", because its version (%2) is less than " + ...
"the one of the WINDEV element (%3)", stAPatch:sName, ...
stAPatch:nVersion, nVersionInAccountPatch)
END
END
// Display the information found
Info(sInfoTakenIntoAccountPatch)
Minimum version required
  • Version 15
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help