Game Maker Games, Articles, Tutorials & More

Game Maker Network


Howdy, Guest! Please sign in or register an account.

Print

ds_map_repr

By Daniel · December 29, 2008

Returns a string representation of the given map

// ds_map_repr(id, multiline)
// Returns a string representation of the given map

var map, s, del, key, pair;

map = argument0;
s = '';
if (argument1)
  del = '#';
else
  del = ', ';

for (key = ds_map_find_first(map);
     ds_map_exists(map, key);
     key = ds_map_find_next(map, key)) {
  if (s != '')
    s += del;
  pair = string(key) + ': ' + string(ds_map_find_value(map, key));
  if (!argument1)
    pair = '(' + pair + ')';
  s += pair;
}

if (!argument1)
  s = '[' + s + ']';
return s;

Comments

There are no comments to display.

Post a Comment

You must be signed in to post comments.

Advertisement