I would use a case statement instead of all your if statements..
take ke a look at case..
Case statement…yea, I'I've wanted to use that structure in several scripts, but I can't find it in the list of available commands in FMPro Advanced v.12. Where IS the case statement?
Ah, I think I've answered my own question. Case is a function, not a script command. Grr! Oh, well, time to explore the Functions documentation.
Well, I've perused the Functions documentation for Case statements, and I don't see a way to make it work the way I need it to work. When the record is displayed, if the field "Period of Day" is empty, apply the value in the field "Time" to a series of conditions (cases) to determine in which the period of day the time falls, then insert a related bit of text (before breakfast, after lunch, etc.) into the field "Period of Day".
The case statement function doesn't seem to let me define the field into which the relevant bit of text should be inserted.
Is there a better way to accomplish this?
Sorry for the wild goose chase... On second thought... It appears you might be able to put this in one if statement...
Just use the else if..
the main thing to remember is scripts work top down.. So if you have criteria that is met at the top... And again at the bottom depending in an if statement only the top one will work...
now in the current way you have yours setup... Only the last criteria met would take effect.
Yep, converted the multiple end-if's into a single nested else-if statement with the problematic time statement as the default value (after final "else"), and now the script works as intended. Kind of a kludge, if you ask me. A case statement would work so well here. (Guess my brain is still wired for 4D databases.) But thanks for the tips!