🐐 LONGITVDO on strings

This commit is contained in:
2026-04-16 18:26:17 +02:00
parent c720d75c79
commit b24134ae4e
4 changed files with 12 additions and 8 deletions

View File

@@ -909,9 +909,9 @@ class BuiltIn(Node):
raise CentvrionError("FORTIS_ELECTIONIS: cannot select from an empty array")
return vtable, lst[random.randint(0, len(lst) - 1)]
case "LONGITVDO":
if not isinstance(params[0], ValList):
raise CentvrionError("LONGITVDO requires an array")
return vtable, ValInt(len(params[0].value()))
if isinstance(params[0], (ValList, ValStr)):
return vtable, ValInt(len(params[0].value()))
raise CentvrionError("LONGITVDO requires an array or string")
case "EVERRO":
print("\033[2J\033[H", end="", flush=True)
return vtable, ValNul()

View File

@@ -481,9 +481,10 @@ CentValue cent_avdi_numerus(void) {
}
CentValue cent_longitudo(CentValue v) {
if (v.type != CENT_LIST)
cent_type_error("'LONGITVDO' requires a list");
return cent_int(v.lval.len);
if (v.type == CENT_LIST) return cent_int(v.lval.len);
if (v.type == CENT_STR) return cent_int((long)strlen(v.sval));
cent_type_error("'LONGITVDO' requires a list or string");
return cent_null(); /* unreachable; silences warning */
}
CentValue cent_fortis_numerus(CentValue lo, CentValue hi) {