SRL Archive - Research & Development Lounge

Var + 1 procedure (like i++)


Kik

2007-08-14 20:02:49

Well, I was tired of writing stuff like timetowait:=timetowait + 1; or something similar to that, so I made this very simple procedure.

procedure var2(var i: integer);
begin
i:= i + 1;
end;

I wanted to make it as small as possible, so I gave it a small name. It simply adds 1 to the variable.

The Element

2007-08-14 20:11:29

remove var from the parameter and have it return an integer. I will make something…


function var2(i : integer): Integer;
begin
result := i + 1;
end;


Not sure if that is right but that is kinda like what I am combineing between what I know and Delphi.

Starblaster100

2007-08-14 20:13:51

[php]
inc(i);
[/php]

The Element

2007-08-14 20:14:40

:p…I guess I should look in the scar manual more :D

Kik

2007-08-14 20:20:14

never knew about that. Thanks for telling me star!

I should look in the manual more, too. I just saw how much info it has a few days ago.

Also, to Element about his function, yours doesn't change i, it only gives the value of i + 1.

3Garrett3

2007-08-14 20:32:04

Umm, I := Var2(I); would work.

dvdcrayola

2007-08-14 22:29:19

ya, but that defeats the purpose of what he was doing.

The Element

2007-08-15 11:09:43

MyInteger := var2(MyInteger);

Or use starblasters.

dvdcrayola

2007-08-15 13:17:44

From: The Element
MyInteger := var2(MyInteger);

Or use starblasters.


the whole point of him making this was so that he didnt have to type so much… and with yours, you still have to type almost as much, or in some cases more.. so he would want to use either his or starblasters

however something more useful might be:


procedure var2(Variable, Amount: integer);
begin
Variable:= Variable + Amount;
end;

then its not something that already exists, i think, and it can be used for more

The Element

2007-08-15 13:20:42

Then use starblasters.

rotflmfwao

2007-08-15 17:29:22

It's not actually starblaster's procedure (at least I don't think so)
All it does is adds one to your variable…
Here's how to test it:
program New;
var
i:Integer;
begin
i:=0
ClearDebug;
Repeat
Writeln('The variable''i''=' +IntToStr(i));
Inc(i);
Until(i=11);
end.

Starblaster100

2007-08-15 17:33:09

No it's not my procedure, i take no credit for it, its already built into SCAR.

[php]
Inc(var);
Dec(var);
[/php]

are the 2 commands you want for the short way of

[php]
var := var + 1;
var := var -1;
[/php]

Kik

2007-08-15 18:06:28

I was just thanking you for showing me them.

rotflmfwao

2007-08-15 20:08:07

Star like, knows everything 'bout scar. He = pwnz. But me = more pwnz :p
I dunno, those asians are pretty difficult to out-auto, legend has it they don't need sleep or food…~tim0suprem0
Lmao

jhildy

2007-08-15 21:07:53

From: dvdcrayola
the whole point of him making this was so that he didnt have to type so much… and with yours, you still have to type almost as much, or in some cases more.. so he would want to use either his or starblasters

however something more useful might be:


procedure var2(Variable, Amount: integer);
begin
Variable:= Variable + Amount;
end;

then its not something that already exists, i think, and it can be used for more


wouldn't work make it say var2(var Variable: integer; amount: integer);

dvdcrayola

2007-08-16 03:06:48

um.. why? you dont usually have to put var right?

rotflmfwao

2007-08-16 17:26:42

No. Thats just to show an output.

R0b0t1

2007-08-16 18:00:10

Heres a better one.


Function Incr(Variable, By: Integer): Integer;
begin;
Result:= Variable + By;
Variable:= Variable + By;
end;

You could use it two ways:


Incr(Variable1, 3);
WriteLn(StrToInt(Variable1));

or


WriteLn(StrToInt(Incr(Variable1, 3)));

Sumilion

2007-08-16 18:06:15

IncEx(var Number: Integer; nInc: Integer);
DecEx(var Number: Integer; nDec: Integer);

R0b0t1

2007-08-16 18:08:05

Ouch. I need an icepack, because I was just BURNED!

dvdcrayola

2007-08-16 18:11:24

From: r0b0t1
Ouch. I need an icepack, because I was just BURNED!


haha, there are a lot of things built into scar that i didnt know about

rotflmfwao

2007-08-16 21:11:14

You know, you could just use sum…

i:=Sum(i,1);

dvdcrayola

2007-08-17 01:54:27

or you could just use inc(i) :p