Browse Source

pastojs: procedure val(const string; out enum; out int)

git-svn-id: trunk@40551 -
Mattias Gaertner 6 years ago
parent
commit
cea0060507
1 changed files with 13 additions and 1 deletions
  1. 13 1
      utils/pas2js/dist/rtl.js

+ 13 - 1
utils/pas2js/dist/rtl.js

@@ -950,7 +950,7 @@ var rtl = {
     };
   },
 
-  floatToStr : function(d,w,p){
+  floatToStr: function(d,w,p){
     // input 1-3 arguments: double, width, precision
     if (arguments.length>2){
       return rtl.spaceLeft(d.toFixed(p),w);
@@ -975,6 +975,18 @@ var rtl = {
     }
   },
 
+  valEnum: function(s, enumType, setCodeFn){
+    s = s.toLowerCase();
+    for (var key in enumType){
+      if((typeof(key)==='string') && (key.toLowerCase()===s)){
+        setCodeFn(0);
+        return enumType[key];
+      }
+    }
+    setCodeFn(1);
+    return 0;
+  },
+
   initRTTI: function(){
     if (rtl.debug_rtti) rtl.debug('initRTTI');