SRL Archive - Research & Development Lounge

Awriteln


jhildy

2007-08-15 19:44:23

yea i was bored and decided to write this its kinda fun for sigs in the beginning of scripts or whatever but yea
program New;

//this writes into the debug box in a progressive order by letters
//with a wait time between letters of wait
Procedure AWriteLn(Text: string; wait: integer);
var i: integer;
begin
for i:=1 to length(text) do
begin
cleardebug;
writeln(copy(text,0,i));
sleep(wait);
end;
end;

begin
Awriteln('Im jhild and im sweet',200);
end.

bullzeye95

2007-08-15 19:52:03

Simple little thing :p

But to make it better, you could do
Procedure AWriteLn(Text: string; wait: integer);
var i: integer;
begin
for i:=1 to length(text) do
begin
DeleteDebugLine(GetDebugLineCount);
writeln(copy(text,0,i));
sleep(wait);
end;
end;
It will get just delete the last line, not the whole debug box.

jhildy

2007-08-15 21:04:52

yea but it doesn't matter that much.

R0b0t1

2007-08-15 21:50:40

Yes it does Jhildy. Unless you cleared it before though.

jhildy

2007-08-15 22:16:36

i clear it every time

dvdcrayola

2007-08-16 02:52:01

just curious, what is the use of this? or was it just for fun.

ZephyrsFury

2007-08-16 04:38:05

Just for fun and making your script look a little better.

Killerdou

2007-08-16 04:50:57

strings start with 1 right not with 0(the first character is character # 1)

ZephyrsFury

2007-08-16 05:03:38

I thought it was 0. Thats why in his procedure it starts and 0 and finishes with i.

R0b0t1

2007-08-16 16:33:11

Arrays in SCAR start with 0, therefore, having a string start with 0 is very logical.

dvdcrayola

2007-08-17 01:57:32

they start with 1, not 0.

i neeeded to know this so i ran a couple of tests to find out.

TOB

2007-08-17 05:47:40

From: dvdcrayola
they start with 1, not 0.

i neeeded to know this so i ran a couple of tests to find out.


Wrong, arrays in every language start with 0. SCAR is no exception.

From: bullzeye95
Simple little thing :p

But to make it better, you could do
Procedure AWriteLn(Text: string; wait: integer);
var i: integer;
begin
for i:=1 to length(text) do
begin
DeleteDebugLine(GetDebugLineCount);
writeln(copy(text,0,i));
sleep(wait);
end;
end;
It will get just delete the last line, not the whole debug box.


Needs to be flopped so it's as such to properly work:

procedure AWriteLn(Text: string; wait: Integer);
var i: Integer;
begin
for i:=1 to Length(text) do
begin
Writeln(copy(text,0,i));
DeleteDebugLine(GetDebugLineCount);
Sleep(wait);
end;
end;

Hugolord

2007-08-17 05:49:13

edit your post! :google: lol jk jk :p nice idea jhildy

TOB

2007-08-17 05:50:54

From: hugolord
edit your post! :google: lol jk jk :p nice idea jhildy


Already did ;)

dvdcrayola

2007-08-17 12:15:04

From: TOB
Wrong, arrays in every language start with 0. SCAR is no exception.
QUOTE]

i was talking about strings..


program New;
{.include SRL\SRL.Scar}


const
VersionNumber = ('1.0');
procedure WriteProgln (TheStr:string; Width:integer;LeftEdge,RightEdge:string);
var lstr,rstr,middle,lch,rch :string;
Left,right,iter,space,sur:integer;
begin

sur:=Pos('WPL surround',TheStr);
if sur<>0 then
begin
lch:= copy(TheStr,sur+13,1);
rch:= copy(TheStr,sur+14,1);
delete(TheStr, 1, 16);
space:=Width-length(TheStr);
if space<0 then space:=0;
if (space mod 2)=0 then
begin
Left:=space/2;
Right:=Left;
end;
if (space mod 2)<>0 then
begin
Left:=round((space/2)-0.5);
Right:=Left+1;
end;
for iter:=0 to left do
lstr:=lstr+lch;
for iter:=0 to right do
rstr:=rstr+rch;
writeln(LeftEdge+lstr+TheStr+rstr+RightEdge);
Exit;
end;

space:=Pos('WPL easter egg',TheStr);
if space<>0 then
begin
for iter:=0 to Width+1 do
middle:=middle+copy(TheStr,space+16,1);

writeln(copy(TheStr,space+15,1)+middle+copy(TheStr,space+17,1));
exit;
end;

space:=Width-length(TheStr);
if space<0 then space:=0;
if (space mod 2)=0 then
begin
Left:=space/2;
Right:=Left;
end;
if (space mod 2)<>0 then
begin
Left:=round((space/2)-0.5);
Right:=Left+1;
end;
for iter:=0 to left do
lstr:=lstr+' ';
for iter:=0 to right do
rstr:=rstr+' ';
writeln(LeftEdge+lstr+TheStr+rstr+RightEdge);
end;

procedure Proggie;
begin
WriteProgln('WPL surround /\ Boreass PowerChopper',50,'|','|')
WriteProgln('WPL easter egg +-+',50,'|','|');
WriteProgln('DvdCrayolas And Dr.Newhearts Varrock Oak Owner',50,'|','|');
WriteProgln('WPL easter egg +-+',50,'|','|');

end;

begin
SetupSRL;
Proggie;
end.

try that.. and then change line 17 to: delete(TheStr, 0, 16);

it wont work right