Jump to content


Photo

Array maker


  • Please log in to reply
1 reply to this topic

#1 jon sploder

jon sploder

    GMC Member

  • GMC Member
  • 859 posts

Posted 31 July 2012 - 10:36 AM

Someone's already probably made something like this, but this script simply takes text in normal format and then pulls it into an array. E.g.

This

Apply
Appreciate
Assess
Calculate

Becomes
in[0] = "Apply";
in[1] = "Appreciate";
in[2] = "Assess";
in[3] = "Calculate";

Code:
starting_variable is the beginning value for your array. ie array[this here]
starting_value = 0;

handle = clipboard_get_text();
working_string = '';

totlines = string_count(chr(13)+chr(10),handle);
show_message(totlines);
var i;
for (i = starting_value; i < totlines+starting_value; i += 1)
{
    before_text = 'out[' +   string(i)   +  '] = "';
    after_text = '";'   +   chr(13)+chr(10);    
    

    working_string += before_text     +    string_copy(handle,0,string_pos(chr(13)+chr(10),handle)-1)    +   after_text;
    handle = string_delete(handle,1,string_pos(chr(13)+chr(10),handle)+1);
}
clipboard_set_text(working_string);

Just thought someone might have a use for this.

Edited by jon sploder, 31 July 2012 - 10:37 AM.

  • 1

#2 Moonsider

Moonsider

    GMC Member

  • GMC Member
  • 440 posts
  • Version:GM8

Posted 17 August 2012 - 09:27 PM

Sweet! Just what I needed!

Tanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users