opsi-winst / opsi-script: Checking if string is in the stringList?
Verfasst: 28 Nov 2017, 15:41
Hello, Is there an elegant way of checking if string is in stringList? For now I am iterating and comparing..
opsi support forum
https://forum.opsi.org/
Code: Alles auswählen
[Actions]
requiredWinstVersion >= "4.12.0.7"
encoding=utf8
LogLevel = "1"
DefVar $Something$
DefStringList $SomethingAllowed$
Set $Something$ = "a"
Set $SomethingAllowed$ = createStringList('ab', 'bc', 'cd')
if not(takeFirstStringContaining($SomethingAllowed$, $Something$) = "")
Comment "I was there.."
endif
Code: Alles auswählen
[6] [Lap 30 16:22:11:132] If
[7] [Lap 30 16:22:11:134] takeFirstStringContaining($SomethingAllowed$, $Something$) = "" <<< result false
[6] [Lap 30 16:22:11:137] not(takeFirstStringContaining($SomethingAllowed$, $Something$) = "") <<< result true
[6] [Lap 30 16:22:11:138] Then
[5] [Lap 30 16:22:11:140] comment: I was there..
[6] [Lap 30 16:22:11:146] EndIf
Code: Alles auswählen
if not(count($SomethingAllowed$) = count(removeFromListByMatch($Something$, $SomethingAllowed$)))
Comment "I was there.."
endif
Code: Alles auswählen
if not(Count(GetListContaining($SomethingAllowed$,$Something$)) = "0")
Comment "I was there.."
endif
;or
if (Count(GetListContaining($SomethingAllowed$,$Something$)) INT> "0")
Comment "I was there.."
endif