SRL Archive - First Scripts

Romeys Auto Talker


Romey

2008-12-01 22:05:28

Hey all I did a comprehensive course in Delphi in high school on programming,
however it has been over 1 year since I have put the skills to use and will be starting off with some basic scripts to get me back in the swing of things.

Here is a simple Auto Talker, 10 customizable words to be spoken at random times, times can be changed by yourself also. Reports on how many words spoken and how long you ran it for.

You have said : 10 words!
Romeys Auto talker has been running 24 Seconds
Successfully executed

Tested and works fine :spot:

any constructive criticism is very accepted. If you check it out and like rep me and rate please.

edit. thanks to sandstorms help, have greatly improved efficiency, reduced code and is now up for download and inspection.

Sandstorm

2008-12-01 22:12:40

I'd suggest you take a look into cases and constants. Would make it a lot shorter and a lot more user friendly. :). Also, if you can at all avoid it (very easy in most cases) DO NOT USE INFINITE LOOPS! ALWAYS HAVE A WAY TO BREAK OUT!. Here's an example of what I mean:


Program New;
{.include srl/srl.scar}

Const
Speak1 = 'Hi';
Speak2 = 'Yo';
Speak3 = 'Sup';

Procedure Speak;
Begin
Case Random(3) Of
0 : Typesend(Speak1);
1 : Typesend(Speak2);
2 : Typesend(Speak3);
End;
End;


Begin
SetupSrl;
Repeat
Speak;
Until(IsFkeyDown(9))
End.

Shorter, more effecient, easier to read. You'd have to re-implement your progress report though.

Romey

2008-12-01 22:18:32

Hey thank you for that makes heaps of sense and very efficient cheers for that info and help =)

Blumblebee

2008-12-01 22:19:57

ummm, coding is very inefficient, your script could easily been done with an array. If you don't know what arrays are, i suggest learning them.

example to shorten your coding,

var
word: Array [0..9] of string;
I: Integer;
procedure speaking;
begin
Word[0]:= 'text here';
Word[1]:= 'text here';
Word[2]:= 'text here';
Word[3]:= 'text here';
Word[4]:= 'text here';
Word[5]:= 'text here';
Word[6]:= 'text here';
Word[7]:= 'text here';
Word[8]:= 'text here';
Word[9]:= 'text here';
for I := 0 to 9 do Typesend(Word[I]);
Wait(1000 + random (30000))
end;

begin
repeat
speaking;
until(False);
end.

not really sure if that compiles ect, but I hope you get the gyst of what I'm saying. You could take your 150 line script, and make it 15 lines.

None the less, nice first script, and I hope to see more from you.

-Blumblebee

Sandstorm

2008-12-01 22:26:18

Blumble, that would be rather inefficient wouldn't it? It's declaring the array every time you run the script. Declare it once at the start, and arrays are WAY more efficient then cases/constants though (I just tend to like cases, check out my signature. Click the picture. Epic case nesting lol).

Blumblebee

2008-12-01 22:36:26

Fine, here

var
word: Array [0..9] of string;
I: Integer;
procedure LoadSpeakArray;
begin
Word[0]:= 'text here';
Word[1]:= 'text here';
Word[2]:= 'text here';
Word[3]:= 'text here';
Word[4]:= 'text here';
Word[5]:= 'text here';
Word[6]:= 'text here';
Word[7]:= 'text here';
Word[8]:= 'text here';
Word[9]:= 'text here';
end;

procedure TalkIt;
begin
for I := 0 to 9 do Typesend(Word[I]);
Wait(1000 + random (30000));
end;

begin
LoadSpeakArray;
repeat
TalkIt;
until(IsFkeyDown(9));
end.

Romey

2008-12-03 00:00:05

Thank you for the constructive criticism I appreciate it greatly, already it has improved the efficiency of my code. THANK YOU~!

NiCbaZ

2008-12-03 01:25:45

var
word: TStringArray;
I: Integer;
procedure LoadSpeakArray;
begin
word:= ['Hello','sup','wassup'];
end;

procedure TalkIt;
begin
for I := 0 to Length(Word) do
Typesend(Word[i]);
Wait(1000 + random (30000));
end;

begin
LoadSpeakArray;
repeat
TalkIt;
until(IsFkeyDown(9));
end.

Shorter + as many talks as you want.

SirPa

2008-12-03 03:58:45

In the main loop you say "Quickly open the RS page!"
This is not needed though, just put a ActivateClient there ;)

Other then that, seems like a nice little autotalker ^^

~Sir

Romey

2008-12-03 08:38:13

From: SirPa
In the main loop you say "Quickly open the RS page!"
This is not needed though, just put a ActivateClient there ;)

Other then that, seems like a nice little autotalker ^^

~Sir


ok cool ty for that will edit change and upload now, ty for that information.