mercredi 2 janvier 2019

multiple conditions in one if statement loaded from a file

I have an if statement in my code that has multiple conditions, like this: if(cond1 || cond2 || cond3 || cond4). These conditions may vary with time and I don't want to edit my code each time they change.

I'd like to store them in a file which would be easier to edit. something like this:

file conditions.txt:

cond1
cond2
cond3
cond4

and then in my code if(loadedFile). My idea was to load the file into an array (\n separator) and then do if(arr[1] || arr[2] || arr[3] || arr[4]) but that can't work since there is an unknown number of conditions.

Aucun commentaire:

Enregistrer un commentaire