// ds_grid_repr(id)
// Returns a string representation of the given grid
var xx, yy, maxlen, s, row;
for (xx = 0; xx < ds_grid_width(argument0); xx += 1) {
// Determine size of column
maxlen = 0;
for (yy = 0; yy < ds_grid_height(argument0); yy += 1)
maxlen = max(maxlen, string_length(string(ds_grid_get(argument0, xx, yy))));
for (yy = 0; yy < ds_grid_height(argument0); yy += 1) {
s = string(ds_grid_get(argument0, xx, yy));
s += string_repeat(' ', maxlen - string_length(s)); // pad
if (xx == 0)
row[yy] = s;
else
row[yy] += ' ' + s;
}
}
s = '';
for (yy = 0; yy < ds_grid_height(argument0); yy += 1) {
if (s != '')
s += '#';
s += row[yy];
}
return s;
Categories: Data processing, String handling
There are no comments to display.
You must be signed in to post comments.