info.mailtraq.com > Management > Script Functions A-Z > For() For()Iterates through each item in a list, reassigning a given variable to the current item on each iteration. For() is a looping function similar to While() and Repeat(), where the content expression is evaluated each cycle.
result := For( list , varname , content )
- list
- A comma separated list of items
- varname
- The name of the variable into which the current list item will be placed during each cycle
- content
- The expression to be evaluated during each loop cycle
- result
- A concatenation of the evaluations through every cycle
Concatenates the numeric position of the letter "b" in each of the items within "my_list" to a variable named "test" my_list := "boat,abacus,rebound";
test := For(my_list, "item",
Pos("b", item)
);
MessageDlg(test)
Writes a list of names and fully qualified mailbox addresses in the console, one per line, to a file named \database\users.txt Define("Name", GetSystemVar("/mailslots/" ++ box ++ "/Description"));
a := CreateFile("users.txt");
For(GetMailboxes(), "box",
If(GetMailboxProp(box, "Type") = "mailbox",
Write(a, "\q" ++ Name() ++ "\q <" ++ box ++ "@" ++ LOCALHOST ++ ">")
)
);
CloseFile(a) |