Jump to content

IF in a MsgBox?


Recommended Posts

Hi everybody,

maybe it is a stupid question, is it possible to filter the values in a MsgBox?

I have some some values dynamically generated, sometimes it might happen that one of them is basically null and i don't want to "print" it together with the others.

Is it possible to add some Kind of filter or if to a Msgbox?

Link to comment
Share on other sites

MsgBox(0,"Daten ermittelt","Daten des Onlineupdates:"&@CRLF&"Heute: "&$datumheute&@CRLF&"   Aufrufe gesamt(Update Requests+Error): "&$anzahl_info_heute+$anzahl_error_heute& _
@CRLF&@TAB&"Update Requests: "&$anzahl_info_heute& _
@CRLF&@TAB&"Error: "&$anzahl_error_heute& _
@CRLF&@TAB&"Parsing client dictionary failed: "&$anzahl_heute_info_parsing_failed& _
@CRLF&"client version: 5.2.00_01.01.2016 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5200&@TAB&"("&$Prozent_MDU_5200&"%)"& _
@CRLF&"client version: 5.2.11_31.08.2010 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5211_31082010&@TAB&"("&$Prozent_MDU_5211_31082010&"%)"& _
@CRLF&"client version: 5.2.11_01.01.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5211_01012017&@TAB&"("&$Prozent_MDU_5211_01012017&"%)"& _
@CRLF&"client version: 5.2.18_18.08.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5218_18082017&@TAB&"("&$Prozent_MDU_5218_18082017&"%)"& _
@CRLF&"client version: 5.2.18_11.09.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5218_11092017&@TAB&"("&$Prozent_MDU_5218_11092017&"%)"& _
@CRLF&"client version: 5.2.18_04.10.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5218_04102017&@TAB&"("&$Prozent_MDU_5218_04102017&"%)"& _
@CRLF&"client version: 5.2.21_09.10.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5221_09102017&@TAB&"("&$Prozent_MDU_5221_09102017&"%)"& _
@CRLF&"client version: 5.2.21_23.10.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5221_23102017&@TAB&"("&$Prozent_MDU_5221_23102017&"%)"& _
@CRLF&"client version: 5.2.21_27.10.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5221_27102017&@TAB&"("&$Prozent_MDU_5221_27102017&"%)"& _
@CRLF&"client version: 5.2.21_14.11.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5221_14112017&@TAB&"("&$Prozent_MDU_5221_14112017&"%)"& _
@CRLF&"client version: 5.2.21_23.11.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5221_23112017&@TAB&"("&$Prozent_MDU_5221_23112017&"%)"& _
@CRLF&"client version: 5.2.21_28.11.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5221_28112017&@TAB&"("&$Prozent_MDU_5221_28112017&"%)"& _
@CRLF&"client version: 5.2.21_13.12.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5221_13122017&@TAB&"("&$Prozent_MDU_5221_13122017&"%)"& _
@CRLF&"client version: 5.2.22_11.11.2017 server version: 5.2.24_28.11.2017 :"&$Counter_MDU_5222_11112017&@TAB&"("&$Prozent_MDU_5222_11112017&"%)")

This is my MsgBox and not all the counters have a value greater than 0

Link to comment
Share on other sites

Lonewolf_2016,

You will need to construct the string outside of the message box testing for values to include...like

Local $str = '', $c1 = 1, $c2 = 0, $c3 = 9

If $c1 > 0 Then $str &= 'Some text and counter = ' & $c1 & @CRLF
If $c2 > 0 Then $str &= 'Some text2 and counter2 = ' & $c2 & @CRLF
If $c3 > 0 Then $str &= 'Some text3 and counter3 = ' & $c3 & @CRLF

MsgBox(0, 'TEXT', $str)

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

This will work also.

Local $str = '', $c1 = -1, $c2 = 0, $c3 = 9

; Using Conditional operator (?:) See: "Language Reference - Operators", or, the "Ternary operator" in AutoIt help file.
MsgBox(0, 'TEXT', _
        ($c1 ? 'Some text  and counter1 = ' & $c1 & @CRLF : '') & _
        ($c2 ? 'Some text2 and counter2 = ' & $c2 & @CRLF : '') & _ ; Zero is false.  Not zero is true.
        ($c3 ? 'Some text3 and counter3 = ' & $c3 & @CRLF : ''))

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...