opsi-winst / opsi-script: Checking if string is in the stringList?
opsi-winst / opsi-script: Checking if string is in the stringList?
Hello, Is there an elegant way of checking if string is in stringList? For now I am iterating and comparing..
Re: opsi-winst / opsi-script: Checking if string is in the stringList?
https://download.uib.de/opsi_stable/doc ... anual.html
code]
takeFirstStringContaining
[/code]
regards,
bardo wolf
code]
takeFirstStringContaining
[/code]
regards,
bardo wolf
Basisworkshop Mainz
08. - 12.12. 24
opsi support - uib gmbh
For productive opsi installations we recommend maintainance + support contracts which are the base of opsi development.
http://www.uib.de
Re: opsi-winst / opsi-script: Checking if string is in the stringList?
Dear Wolf, that is not really what I was asking.. In many situations I have some kind of value and need to check if it is or it is not in some kind of a list (blacklist, whitelist, etc..).. "Contains" is not what I need.. I need "equals"! Funny things could happen with "contains" (ex. paths)..
would result true:
Funny way of doing it could be:
There should be a better way of checking it element is in a list..
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
Re: opsi-winst / opsi-script: Checking if string is in the stringList?
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
Re: opsi-winst / opsi-script: Checking if string is in the stringList?
larsg: The problem is with ..Containing – string - substring:)
The solution: getSubListByMatch (<search string>, <target list>) :stringlist //since 4.12.0.14
Thank you, OPSI developers!
The solution: getSubListByMatch (<search string>, <target list>) :stringlist //since 4.12.0.14
Thank you, OPSI developers!