Jump to content


Photo

Automatically line break


  • Please log in to reply
6 replies to this topic

#1 gameside

gameside

    GMC Member

  • GMC Member
  • 70 posts

Posted 17 August 2012 - 01:33 PM

hello there!
i made a program works like [notepad.exe] when you writing it automatically save what you type in .txt, the problem is until you didn't press the enter key, all the words going in one line
and if you then open .txt saved file you see that all the words are written through one line [no line break] :mellow:
i want to know is it possible to make Automatic Line Break in game maker that when the e.g [line>30 character or words] make an Automatically line break.

***any script is appreciated*** :biggrin:
  • 0

#2 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1452 posts
  • Version:GM8.1

Posted 17 August 2012 - 01:58 PM

well, this code should save the string argument1 to the text file argument0:
var f,s;
f=file_text_open_write(argument0);
argument1+="
";
s=string_copy(argument1,1,string_pos("
",argument1)-1);
while string_length(argument1){
file_text_write_string(f,s);
file_text_writeln();
argument1=string_copy(argument1,string_length(s)+3,string_length(argument1)-string_length(s)-2);
s=string_copy(argument1,1,string_pos("
",argument1)-1);
}
file_text_close(f);

if you really want to save it constantly, just activate this every time something changed, else use it when you shut it down.

EDIT: just noticed it wasn't where you were searching for, sorry, will post a new comment.

Edited by jo-thijs, 17 August 2012 - 01:59 PM.

  • 0

#3 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1452 posts
  • Version:GM8.1

Posted 17 August 2012 - 02:03 PM

I found an old script of mine that transforms a string so that it would display the same with or without gamemakers automatic line break:

// arg0 = the text
// arg1 = the width

var remaining,current,line_start,prev_space;
remaining=argument0;
current="";
line_start=0;
prev_space=0;

while string_length(remaining) {

if string_char_at(remaining,1)==" "||string_char_at(remaining,1)=="
" {

if string_width(string_copy(current,line_start,string_length(current)-line_start))>=argument1 && prev_space {

current=string_copy(current,1,prev_space)+"
"+string_copy(current,prev_space+1,string_length(current)-prev_space);
line_start=prev_space+1;

}

//if string_char_at(remaining,1)==" "
prev_space=string_length(current);

}

current+=string_char_at(remaining,1);
remaining=string_copy(remaining,2,string_length(remaining)-1);

}

if string_width(string_copy(current,line_start,string_length(current)-line_start))>=argument1 && prev_space
current=string_copy(current,1,prev_space)+"
"+string_copy(current,prev_space+1,string_length(current)-prev_space);

return current;
  • 0

#4 gameside

gameside

    GMC Member

  • GMC Member
  • 70 posts

Posted 17 August 2012 - 04:54 PM

I found an old script of mine that transforms a string so that it would display the same with or without gamemakers automatic line break:

// arg0 = the text
// arg1 = the width

var remaining,current,line_start,prev_space;
remaining=argument0;
current="";
line_start=0;
prev_space=0;

while string_length(remaining) {

if string_char_at(remaining,1)==" "||string_char_at(remaining,1)=="
" {

if string_width(string_copy(current,line_start,string_length(current)-line_start))>=argument1 && prev_space {

current=string_copy(current,1,prev_space)+"
"+string_copy(current,prev_space+1,string_length(current)-prev_space);
line_start=prev_space+1;

}

//if string_char_at(remaining,1)==" "
prev_space=string_length(current);

}

current+=string_char_at(remaining,1);
remaining=string_copy(remaining,2,string_length(remaining)-1);

}

if string_width(string_copy(current,line_start,string_length(current)-line_start))>=argument1 && prev_space
current=string_copy(current,1,prev_space)+"
"+string_copy(current,prev_space+1,string_length(current)-prev_space);

return current;


i have two question 1) is this script for automatically line break in .txt file ? if yes!
2)then where should i put the to which one [Create,step or draw]
  • 0

#5 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1452 posts
  • Version:GM8.1

Posted 17 August 2012 - 05:34 PM

what do you mean with automatic line break in .txt file?
  • 0

#6 gameside

gameside

    GMC Member

  • GMC Member
  • 70 posts

Posted 18 August 2012 - 02:32 AM

what do you mean with automatic line break in .txt file?


sorry for the late post because last knight our electricity was gone and i can post write on time.
as i mentioned an automatic line break when the character or words in a line>30 word so make a line break [without any pressing enter key].

as e.g[On the Insert tab, the galleries include items that are designed to coordinate with the overall look of your document.] i write these in one line and the program automatically divide it in to lines
e.g
1line[On the Insert tab, the galleries include items]
2line[that are designed to coordinate with the overall]
3line[look of your document.]
  • 0

#7 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1452 posts
  • Version:GM8.1

Posted 18 August 2012 - 09:55 AM

well, try to use the output of the second script in the first script and if there's something wrong, I'll make a new script.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users