Advertisement
Guest User

ds_map_access

a guest
Jan 26th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///@desc Accesses a map .
  2. ///@param map
  3. ///@param keys...
  4.  
  5. var ds = argument[0];
  6.  
  7. var key = undefined;
  8. var val = undefined;
  9.  
  10. for (var i=1;i<argument_count;i++) {
  11.     key = argument[i];
  12.     val = ds[? key];
  13.    
  14.     if (is_undefined(val)) {
  15.         // we failed to find a nested value
  16.         // just return it now
  17.        
  18.         return undefined;
  19.     }
  20.    
  21.     if (i < argument_count-1) {
  22.         if ds_exists(val, ds_type_map) {
  23.             // we're not at the last argument, so change the map target
  24.             // AND
  25.             // a map exists at the value we requested
  26.        
  27.             ds = val;
  28.         }
  29.     }
  30. }
  31.  
  32. return val;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement