Array Index prüfen?
Hallo ich habe eine Mehrfachauswahl mit Mo-So (Hat den Index 1-7 vergeben!)
jetzt möchte ich ein Datum überprüfen ob dieser Wochentag aktiv ist.
let myWochentag := weekday(myDate) + 1;
if item(ArrayWochentage, myWochentag) != "" then
A...
else
B...
end;
5 replies
-
Hallo Micha,
bitte versuche es einmal mit (wenn dein Array ein numerisches Array ist):
...
if myWochentag in [ArrayWochentage] then
....
sonst könnte man auch über den Text gehen mit:
let myWochentag := weekdayName(myDate);
if myWochentag like chosen(meinMehrfachauswahlfeld) then
....
Gruß, Jörg
-
Hi Jörg!
May you explain how to use this:
if myWochentag in [ArrayWochentage] then
—-
because when I try something like
let myArray:=[1,2,3,4.5];
let y :=5;
if y in [myArray] then... it doesn’t work
thank you
-
Agiorno,
It's not the same thing. What Jörg describes is how to compare the selected value in a Choice field to another value. The [ArrayWochentage] or [ArrayWeekdays] returns the selection of the Choice field and is a single value. On a side note, the keyword "in" does not appear to work as I had to use "=" instead.
-
Interesting behavior... Using a Choice field with days of the week which I called Weekdays, duh, I observed the following...
If Wednesday is selected:
[Weekdays] = 3 is True
number([Weekdays]) = 3 is True
[Weekdays] = "Wednesday" is False
text([Weekdays]) = "Wednesday" is True
-
Agiorno, I got distracted. Something like this would accomplish what you want if someone isn't able to offer something more concise...
let myArray := [1, 2, 3, 4, 5];
let y := 5;
let myCount := count(myArray);
let i := 0;
let found := false;
while i < myCount and not found do
if y = item(myArray, i) then found := true else i := i + 1 end
end
Content aside
- 5 yrs agoLast active
- 5Replies
- 1946Views