0

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

null
    • Jorg
    • 5 yrs ago
    • Reported - view

    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

    • agiorno
    • 4 yrs ago
    • Reported - view

    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

    • Sean
    • 4 yrs ago
    • Reported - view

    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.  

    • Sean
    • 4 yrs ago
    • Reported - view

    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

    • Sean
    • 4 yrs ago
    • Reported - view

    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

  • 4 yrs agoLast active
  • 5Replies
  • 1935Views