gNumTimes, gChecklist and gDateStart should be global fields. I was not clear on the values in your value list. It sounded like you've created one for each day of week. Anyway, this is based upon checklist with only 2, 3, 4, 5, 6 in the custom vl. Then script might look like this (assuming fired on Student layout):
CREATE STUDENT CLASSES
# test for empty criteria
If [ not Students::gDateStart or not Students::gNumTimes or IsEmpty ( Students::gChecklist ) ]
Show Custom Dialog [ Message: "Requires Start Date, Number of Records, and Day of Weeks"; Buttons: “OK” ]
Set Variable [ $studentID; Value:Students::StudentID ]
Go to Layout [ “Classes” (Classes) ]
# loop through the dates to set
Exit Loop If [ $days ≥ Students::gNumTimes ]
If [ Let ( $i = $i + 1 ; not IsEmpty ( FilterValues ( DayOfWeek ( Students::gDateStart + $i ) ; Students::gChecklist ) ) ) ]
Set Field [ Classes::StudentiD; $studentID ]
Set Field [ Classes::ClassDate; Let ( $days = $days + 1 ; Students::gDateStart + $i ) ]
# It is not clear where you would like to end up. If back on Students, include a Go To Layout [ original ] here
... and if you need assistance with adjusting it to your value list, let us know. :^)
Also it was not clear what to do if the start date WAS one of the checked days. As is, it would NOT evaluate the current date and only begin evaluating on the next day.
We can adjust this as well.
Thanks for the information and script.
I figured out how this works: I changed the value list to include days of the week and used the DayName() function to do the filtering, but the script works perfectly. It quickly assigns the correct days.
Thanks a lot.