diff options
author | Eugene Sandulenko | 2016-07-09 13:19:51 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | bb8fd6a8990f8364fc6411ba98ec4716429c98d8 (patch) | |
tree | 30f7cb4b9851f53745dd71d1036bc681a0f3b32a /engines/director | |
parent | 40856e6d06c4a71ccabcafcacaebc8fa23549ca3 (diff) | |
download | scummvm-rg350-bb8fd6a8990f8364fc6411ba98ec4716429c98d8.tar.gz scummvm-rg350-bb8fd6a8990f8364fc6411ba98ec4716429c98d8.tar.bz2 scummvm-rg350-bb8fd6a8990f8364fc6411ba98ec4716429c98d8.zip |
DIRECTOR: Lingo: Implemented length() built-in function
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/lingo/lingo-builtins.cpp | 15 | ||||
-rw-r--r-- | engines/director/lingo/lingo.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp index 48de072254..696aca1cfa 100644 --- a/engines/director/lingo/lingo-builtins.cpp +++ b/engines/director/lingo/lingo-builtins.cpp @@ -35,6 +35,7 @@ static struct BuiltinProto { { "exp", Lingo::b_exp, 1}, { "float", Lingo::b_float, 1}, { "integer",Lingo::b_integer, 1}, + { "length", Lingo::b_length, 1}, { "log", Lingo::b_log, 1}, { "pi", Lingo::b_pi, 0}, { "power", Lingo::b_power, 2}, @@ -97,6 +98,20 @@ void Lingo::b_integer() { g_lingo->push(d); } +void Lingo::b_length() { + Datum d = g_lingo->pop(); + + if (d.type != STRING) + error("Incorrect type for 'length' function: %d", d.type); + + int len = strlen(d.u.s->c_str()); + delete d.u.s; + + d.u.i = len; + d.type = INT; + g_lingo->push(d); +} + void Lingo::b_log() { Datum d = g_lingo->pop(); d.toFloat(); diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h index 8cb454f3aa..eca9b4107c 100644 --- a/engines/director/lingo/lingo.h +++ b/engines/director/lingo/lingo.h @@ -220,6 +220,7 @@ public: static void b_exp(); static void b_float(); static void b_integer(); + static void b_length(); static void b_log(); static void b_pi(); static void b_power(); |