Your While() loop is perfectly fine. There isn't a single thing wrong with it. Don't change it if that's how you want to use it.
Your problem is this line:
Think about what you are doing there for a second. Let's break it down:
Code: Select all
var v1 := staffList[i]; //v1 := "staff";
var v2 := name[v1]; //v2 := {error = Uninitialized object};
var v3 := lower(v2); //v3 := "error: Uninitialized Object";
if (v3) //v3 is now a string literal. So this is TRUE
...
The problem is your call to lower() is converting whatever the result is from the inner statements into a string literal.
You need to do it this way:
Code: Select all
var lowername := lower(name);
if (lowername[staffList[i]])
...
While you are at it, your list of names has two problems that maybe are minor.
First, you don't have 'lady' in it, though you have 'lord'.
Second, your list would prevent a name like 'paradigm' because it just checks for 'gm' together. Maybe split the check for 'gm' into a separate check to see if the name starts with 'gm', like so: