This patch adds the VALUELABEL function for use in expressions, which
[pspp-builds.git] / src / language / expressions / operations.def
index 03861021c4f4863ebcf5976710c8e893a53ebfe9..6f0bd0e1430a3f4bcbf1a0742fef8303bb6918ab 100644 (file)
@@ -318,6 +318,12 @@ function XDATE.WEEK (date >= DAY_S)
 function XDATE.WKDAY (date >= DAY_S) = calendar_offset_to_wday (date / DAY_S);
 function XDATE.YEAR (date >= DAY_S) = calendar_offset_to_year (date / DAY_S);
 
+// Date arithmetic functions.
+function DATEDIFF (date1, date2, string unit) = unimplemented;
+function DATESUM (date, quantity, string unit) = unimplemented;
+function DATESUM (date, quantity, string unit, string roll_over)
+     = unimplemented;
+
 // String functions.
 string function CONCAT (string a[n])
      expression e;
@@ -607,6 +613,17 @@ absorb_miss string function SUBSTR (string s, ofs, cnt)
     return empty_string;
 }
 
+absorb_miss no_opt string function VALUELABEL (var v)
+     expression e;
+     case c;
+{
+  const char *label = var_lookup_value_label (v, case_data (c, v));
+  if (label != NULL)
+    return copy_string (e, label, strlen (label));
+  else
+    return empty_string;
+}
+
 // Artificial.
 operator SQUARE (x) = x * x;
 boolean operator NUM_TO_BOOLEAN (x)