// arg = "stepNx" will return N * 10 + <letters a-i transmogrified into digits 1-9>
int numerify(string arg)
{
int max_steps = 12;
matcher m_step = create_matcher("^step(\\d+)([a-i]?)$", arg);
switch {
case arg == "unstarted": return -1;
case arg == "started": return 0;
case arg == "finished": return max_steps * 10 + 10;
case arg == "step0": break;
case find(m_step): //for i from 0 to 2 print("group " + i + " = \"" + group(m_step, i) + "\"");
string d = group(m_step, 1);
string s = group(m_step, 2);
// if d <= max_steps && there's no extra "0"s return maths
if (length(d) <= (d.to_int() > max_steps ? 0 : (d.to_int() > 9 ? 2 : 1))) return d.to_int() * 10 + (s == "" ? 0 : index_of("_abcdefghi", s));
}
nb_abort("\"" + arg + "\" doesn't make any sense at all.");
return -11;
}
boolean is_at_least(string a_string, string b_string)
{
if (numerify(a_string) >= numerify(b_string)) return true;
else return false;
}
boolean is_past(string a_string, string b_string)
{
if (numerify(a_string) > numerify(b_string)) return true;
else return false;
}
boolean is_not_yet(string a_string, string b_string)
{
if (numerify(a_string) < numerify(b_string)) return true;
else return false;
}