Log in

View Full Version : [Resolved]How do you create a new line in a string



LordJashin
02-26-2012, 09:27 PM
When using WriteLn or just strings in general in Simba is there any way to bump them down a line.
Like in C++ there's escape sequences, I know here you can use '' to put a single quote in.
If anyone has a link to like an escape sequences list for Simba that would be nice :D.

Simba Code:

WriteLn('aaaaaaaaaaaaa');
WriteLn('text is on a new line');

Sex
02-26-2012, 09:29 PM
Character 13 and character 10.

Writeln('First line' #13#10 'Second line.');
Writeln('First line' + chr(13) + chr(10) + 'Second line.');

LordJashin
02-26-2012, 09:29 PM
Character 13 and character 10.
Simba Code:

Writeln('First line' #13#10 'Second line.');
Writeln('First line' chr(13) + chr(10) + 'Second line.');





Thx fast as usual <3

Sex
02-26-2012, 09:32 PM
Thx fast as usual <3

Or,
procedure WritelnEx(str : string);
begin
str := Replace(str, '\n', #13#10, [rfReplaceAll]);
Writeln(str);
end;
:)

LordJashin
02-26-2012, 09:35 PM
Or,
Simba Code:

procedure WritelnEx(str : string);
begin
str := Replace(str, '\n', #13#10, [rfReplaceAll]);
Writeln(str);
end;


:)

Yay \n is back :D
Edit: <3 replace

Sex
02-26-2012, 09:36 PM
Yay \n is back :D

If you want to be able to escape \n, you can just modify that procedure :).

Dgby714
02-26-2012, 10:27 PM
I was bored...

program new;

function Wee(const s: string): string;
var
H, I: LongInt;
SearchArr, ReplaceArr: TStringArray;
begin
SearchArr := ['0', 'a', 'b', 't', 'n', 'f', 'r', 'e'];
ReplaceArr := [#0, #7, #8, #9, #10, #12, #13, #27];
Result := Replace(s, '\\', #0'REPLACEMEBACKSPACES'#0, [rfReplaceAll]);

H := High(SearchArr);
for I := 0 to H do
Result := Replace(Result, '\' + SearchArr[I], ReplaceArr[I], [rfReplaceAll]);

Result := Replace(Result, #0'REPLACEMEBACKSPACES'#0, '\', [rfReplaceAll]);
end;

begin
WriteLn(Wee('Test \r\n Wtf \\n Wee'));
end.

LordJashin
02-26-2012, 11:03 PM
So...someone link me to something that tells what these do
#0, #7, #8, #9, #10, #12, #13, #27

Nvm, is there anymore then those?

Here we go - http://villavu.com/forum/showthread.php?t=60451