Hello,
Can someone offer some guidance on how I can better update a variable in a GUI label?
In my script i have pre-defined a text message "$Message" which includes several variables. One of those variables "$Masterversion" is updated based on the Case statement selected. When I run the script, the $Masterversion variable is not updating with the GUICtrlSetData command when the GUI is displayed. What do i need to do to update the $Message string with the new $Masterversion variable?
Here is my script...which has been simplified down to the bare bones to just show the issue.
;Script Start
$SoftwareA = "1.20"
$SoftwareB = "4.6"
$SoftwareC = "2.8"
$SoftwareD = "5.1"
_Software() ;Returns $Software value
_Check()
Exit
Func _Check()
$InstalledVersion = RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\keyname", "value")
$Masterversion = ""
$Message = " This software is out of date!" & @CRLF & @CRLF & " installed version...... " & $InstalledVersion & @CRLF & " current version........ " & $Masterversion & @CRLF & @CRLF & " Please contact your system administrator"
$GUIForm = GUICreate("", 597, 438+57, -1, -1, BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUISetBkColor(0x000000) ;Black
$Label1 = GUICtrlCreateLabel("*** NOTICE ***", 27, 32, 550, 81, BitOR($SS_CENTER,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont(-1, 48, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFF0000) ;Red
GUICtrlSetBkColor(-1, 0x000000) ;Black
$Label2 = GUICtrlCreateLabel($Message, 27, 152, 550, 250, BitOR($WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFF00) ;Yellow
GUICtrlSetBkColor(-1, 0x000000) ;Black
$Button1 = GUICtrlCreateButton("OK", 248, 368+57, 100, 50, BitOR($BS_DEFPUSHBUTTON,$BS_CENTER,$BS_PUSHLIKE))
GUICtrlSetFont(-1, 16, 800, 0, "Arial")
GUISetState(@SW_HIDE)
GUICtrlSetOnEvent($Button1, "_UpdateProcess")
Select
Case $Software = "A"
Local $String = StringInStr($SoftwareName, "XXXX")
If $String <> 0 Then
$Masterversion = $SoftwareA
If $InstalledVersion < $SoftwareA Then
GUICtrlSetData($Label2, $Message)
GUISetState(@SW_SHOW, $GUIForm)
EndIf
EndIf
Case $Software = "B"
Local $String = StringInStr($SoftwareName, "XXXX")
If $String <> 0 Then
$Masterversion = $SoftwareB
If $InstalledVersion < $SoftwareB Then
GUICtrlSetData($Label2, $Message)
GUISetState(@SW_SHOW, $GUIForm)
EndIf
EndIf
Case $Software = "C"
Local $String = StringInStr($SoftwareName, "XXXX")
If $String <> 0 Then
$Masterversion = $SoftwareC
If $InstalledVersion < $SoftwareC Then
GUICtrlSetData($Label2, $Message)
GUISetState(@SW_SHOW, $GUIForm)
EndIf
EndIf
Case $Software = "D"
Local $String = StringInStr($SoftwareName, "XXXX")
If $String <> 0 Then
$Masterversion = $SoftwareD
If $InstalledVersion < $SoftwareD Then
GUICtrlSetData($Label2, $Message)
GUISetState(@SW_SHOW, $GUIForm)
EndIf
EndIf
Case $Software = "E"
Case $Software = "F"
Case $Software = "G"
Case $Software = "H"
Case $Software = "I"
Case $Software = "J"
Case $Software = "K"
Case Else
;Display message
EndSelect
While 1
Sleep(40) ; Idle around
WEnd
EndFunc