SRL Archive - OSR Help

Writing Consts values


Le Jingle

2012-06-21 00:46:27

hi, basically I'm trying to writeln the values I have in my consts (example below);

Program AutoSpammer;
{$i SRL\SRL.Simba}
Const
a = 0;
b = 1;

Procedure ActuallyWrite;
Var
i: Integer;
Begin
For i := 0 to 1 Do
WriteLn([i]);
End;

Begin
SetupSRL;
ActuallyWrite; // Should type Write Line this letter: a
// Should type Write Line this letter: b
End.
(This writes, but not what I want; )

SRL Compiled in 0 msec
[0]
[1]
Successfully executed.


So overall, I can't figure out how to write the 'a' and then 'b' that I have stored as 0 and 1. (I need to keep the 0 and 1 relations to a and b, respectively in the consts)

Any help is highly appreciated! :>

Cheers

Brandon

2012-06-21 00:50:26

You're not actually writing A or B. You're writing The amount of iterations your loop is doing.

I think you're trying to do:


for I:= 0 To 1 Do
WriteLn('WriteLn: A:' + ToStr(A) + ' B: ' + ToStr(B));

Runaway

2012-06-21 00:52:39

You've stored values in a and b, but they are just values. You would need to do:


Writeln(a);
Writeln(b);

To write the the stored values in a and b.

riwu

2012-06-21 00:53:07

U dont fully understand for loops; it doesn't work this way. If u want to write ur const, just
Writeln(IntToStr(a));  //converts integer a to string
Writeln(IntToStr(b));

For loops is basically exactly the same as repeat…until loop except it automatically increases "i" by one and stops when i reaches the end value, i.e. its the same as
repeat
action1;
Inc(i);
until (i=1);

Le Jingle

2012-06-21 01:05:42

Ah so if I understand, since I've stored values for a and b in the consts, I can't reverse the process - writing a or b from the const since they themselves are storing the values (it's not a 2-way street, meaning I'd have to flip flop them*?).

* = Example below

Const
1 = a;
2 = b;

Runaway

2012-06-21 01:22:09

From: Le Jingle
Ah so if I understand, since I've stored values for a and b in the consts, I can't reverse the process - writing a or b from the const since they themselves are storing the values (it's not a 2-way street, meaning I'd have to flip flop them*?).

* = Example below
[simba) snip! (/simba]



Brandon

2012-06-21 01:52:56

LOL ahaha I actually had a good laugh reading the flip-flop.

Anyway you cannot flip-flop them. Quick explanation that I hope I didn't go overboard with:

Consts are constant values. They cannot change during run-time (basically cannot change after u pressed play). Your code should not try to change them either because they always stay the exact same. Hence the word constant.

Now a constant can be assigned to once and a constant is either A: variable, B: value.

Variables as we know, can be assigned to but values cannot be assigned to and do not change unless change by YOU.

Example:

const //Declares that the values declared after this are constants and will not change at all!

A = 1; //A has a CONSTANT value of 1 and A will never change throughout the script.
B = 2; //B has a constant value of 2 and never changes at all unless you manually edit the script and change it.


1 = A; //Illegal. We cannot do this because 1 is already a constant in itself. It's like trying to say 1 = 2. Doesn't work. Both are constant and never change.
//Only variables can change, remember that. Constants are just a special type of variable that doesn't change.
//Values are not variables, but they are by definition "TRUE" constants.

My first teacher told me: Imagine being in bed with a 100% girl and all of a sudden she turns tranny on you. Shouldn't happen because she's 100% constant girl.

Le Jingle

2012-06-21 02:56:50

From: Brandon
LOL ahaha I actually had a good laugh reading the flip-flop.

Anyway you cannot flip-flop them. Quick explanation that I hope I didn't go overboard with:

Consts are constant values. They cannot change during run-time (basically cannot change after u pressed play). Your code should not try to change them either because they always stay the exact same. Hence the word constant.

Now a constant can be assigned to once and a constant is either A: variable, B: value.

Variables as we know, can be assigned to but values cannot be assigned to and do not change unless change by YOU.

Example:

const //Declares that the values declared after this are constants and will not change at all!

A = 1; //A has a CONSTANT value of 1 and A will never change throughout the script.
B = 2; //B has a constant value of 2 and never changes at all unless you manually edit the script and change it.


1 = A; //Illegal. We cannot do this because 1 is already a constant in itself. It's like trying to say 1 = 2. Doesn't work. Both are constant and never change.
//Only variables can change, remember that. Constants are just a special type of variable that doesn't change.
//Values are not variables, but they are by definition "TRUE" constants.

My first teacher told me: Imagine being in bed with a 100% girl and all of a sudden she turns tranny on you. Shouldn't happen because she's 100% constant girl.


hahah! this is a great lesson to have been learned by me! Thanks a ton, plus it really sticks in your head, the way you explained it :p & :)

So in hopes of learning as well as easing my workload for using this in a high repetition manner, if I did this (see code below), how would I go through and write all the lines of strings stored in the constants? *marked the line towards the end


Const
A_String = 'WeNeedToWriteThis1';
B_String = 'WeNeedToWriteThis2';
C_String = 'WeNeedToWriteThis3';
D_String = 'WeNeedToWriteThis4';
E_String = 'WeNeedToWriteThis5';
LeStrings = 'WeNeedToWriteThis6';

Var
i, g: Integer;
LeStrings: TStringArray;

Begin
ClearDebug;
g := High(LeStrings);
For i:= 0 To g Do
Begin
WriteLn('What String we are writing:' + {The 1st Const stored String} + '.');
Wait(5000);
TypeByte(vk_down);
WriteLn('What String we are writing:' + {The 2nd Const stored String} + '.');
Wait(5000);
TypeByte(vk_down);
WriteLn('What String we are writing:' + {The 3rd Const stored String} + '.');
Wait(5000);
TypeByte(vk_down);
{Any way to also shorten this (array somehow, but all my attempts are failures)
so when its used thousands of time, it's not write, wait, mmouse?}
End;
End.

putonajonny

2012-06-21 05:38:25

Is this what you are looking for:
Const
A_String = 'WeNeedToWriteThis1';
B_String = 'WeNeedToWriteThis2';
C_String = 'WeNeedToWriteThis3';
D_String = 'WeNeedToWriteThis4';
E_String = 'WeNeedToWriteThis5';
F_String = 'WeNeedToWriteThis6';

Var
i, g: Integer;
LeStrings : TStringArray;

Begin
ClearDebug;
LeStrings := [A_String, B_String, C_String, D_String, E_String, F_String];
g := High(LeStrings);
For i:= 0 To g Do
Begin
WriteLn('What String we are writing: ' + LeStrings[i] + '.');
Wait(5000);//If this is for runescape don't use static waits, either do Wait(4000+Random(2000)); or wait(RandomRange(4000, 6000));
TypeByte(vk_down);
End;
End.