SRL Archive - Help and Support

{$ Symbols.


R0b0t1

2007-08-26 21:44:45

Yeah, I've seen them before…


but the first time I saw them, I was like, WTF.


I know they are special… They go italicized in SCAR.



EDIT: Can you say: Propaganda

Smartzkid

2007-08-26 21:52:57

I believe they're called compiler directives.

I know what they do, but I have no idea how to use them, or I'd give you an example.

Search for it, there's a few bits of code lingering around here with 'em.

Boreas

2007-08-26 22:08:33

Wait for SCAR 3.12. Since RearrangeTPA is in SCAR 3.12, there will be a compiler directive in DoorProfiles.scar, so that it will ignore the one in the include if you are using 3.12+, you will be able to use that as an example. I might bug Freddy into writing a tut on them.

R0b0t1

2007-08-26 22:10:11


program CompilerDirectives;
{$Define SomeWord}
begin
{$IfDef Hello} //Will not print Hello world
WriteLn('Hello World');
{$Else}
WriteLn('Hello Mars');
{$EndIf}
end.

The magic search button!

Could freddy add more? That might be a cool feature…

EDIT: Do compiler directives work inside loops/if..thens? Or are they always "seen"?

SKy Scripter

2007-08-26 22:38:41

took this out of Test folder…


program DiviDirective;
begin
{$IfDef Divi}
{$IfDef Scar312}
WriteLn('This is SCAR Divi 3.12 or higher!');
{$Else}
WriteLn('This is SCAR Divi 3.05 to 3.11!');
{$EndIf}
{$Else}
WriteLn('This is SCAR Divi 3.04 or lower!');
{$EndIf}
end.

Bobarkinator

2007-08-26 22:41:14

I think I've seen some, like I one time saw Spky do:
{Allow API Calls}

I think freddy should make a tut on all the stuff that's not in the manual ;)

bullzeye95

2007-08-26 22:50:59

From: bobarkinator
I think I've seen some, like I one time saw Spky do:
{Allow API Calls}

I think freddy should make a tut on all the stuff that's not in the manual ;)


He was leaving a comment for you; that does nothing :p

Bobarkinator

2007-08-26 22:57:08

Lol I wondered :p I still think freddy should make that tut and I have seen the other "real" kind :p

The Claw

2007-08-27 03:34:37

$ is hex I think. (asked wizzup about it the other day)

used like this:

If x = $0 Then x := $106;
If y = $0 Then y := $AA;

not sure how to implement into a script though.

Santa_Clause

2007-08-27 03:37:21

I use hex colours for my forms…when making a white background:

SantyForm.Background.Color := $FFFFFF;

The Claw

2007-08-27 03:40:28

yea, but wizzup does all this weird stuff in the script that i pulled that from lol. which is what i was referring to. what you just did there is a pretty obvious way of using them :p lol.

Santa_Clause

2007-08-27 04:23:42

Shutup noob :p

Meh…it's probably just an easier way of declaring the most obvious colours.

Bobarkinator

2007-08-27 08:07:30

From: The Claw
$ is hex I think. (asked wizzup about it the other day)

used like this:

If x = $0 Then x := $106;
If y = $0 Then y := $AA;

not sure how to implement into a script though.



I think Ben knows that also :). Taken from Math.scar:
{*******************************************************************************
function Hash(Str: String): LongInt;
By: BenLand100
Description: For your hashing pleasures ;) Returns a hash value for a string
*******************************************************************************}

function Hash(Str: string): LongInt;
var
i, x: Integer;
begin
Result := 0;
for i := 1 to Length(Str) do
begin
Result := (Result shl 4) + Ord(Str[i]);
x := Result and $F0000000;
if (x <> 0) then
begin
Result := Result xor (x shr 24);
Result := Result and (not x);
end;
end;
Result := (Result and $7FFFFFFF);
end;

I don't get that Result and part

Markus

2007-08-27 08:19:33

{$.*} are compiler directives
$[0-9ABCDE]* is a hexidecimal number

The Claw

2007-08-27 08:25:51

From: bobarkinator
I think Ben knows that also :). Taken from Math.scar:
{*******************************************************************************
function Hash(Str: String): LongInt;
By: BenLand100
Description: For your hashing pleasures ;) Returns a hash value for a string
*******************************************************************************}

function Hash(Str: string): LongInt;
var
i, x: Integer;
begin
Result := 0;
for i := 1 to Length(Str) do
begin
Result := (Result shl 4) + Ord(Str[i]);
x := Result and $F0000000;
if (x <> 0) then
begin
Result := Result xor (x shr 24);
Result := Result and (not x);
end;
end;
Result := (Result and $7FFFFFFF);
end;

I don't get that Result and part


yeh same. would be great if someone could teach us lol

Spky

2007-08-27 09:31:39

That's all bitwise stuff.

shl = Shift bits left
shr = Shift bits right
xor = Exclusive or
etc, etc

n3ss3s

2007-08-27 10:39:40

What does this "Shifting" mean?

rkroxpunk

2007-08-27 14:05:29

*feels like an absolute dumbass*

I'm not following anything you guys are saying :D

SKy Scripter

2007-08-27 17:00:57

Use The Calculater to get Hex Decimals

R0b0t1

2007-08-27 17:19:34

Ahhh… never knew about the bitshifting stuff.

Ok, new question, Can you guys give me the awesome shizz that only 1337 people know? (OR, continue on my first question…)

Wizzup?

2007-08-28 06:09:19

From: The Claw
$ is hex I think. (asked wizzup about it the other day)

used like this:

If x = $0 Then x := $106;
If y = $0 Then y := $AA;

not sure how to implement into a script though.


It was more like a small joke.. Hex colors as you call it are just normal colors, it's still a number, and SCAR auto converts hex to dec. Try using a IntToStr with hex, it works.

The Claw

2007-08-28 07:15:25

From: Wizzup?
It was more like a small joke.. Hex colors as you call it are just normal colors, it's still a number, and SCAR auto converts hex to dec. Try using a IntToStr with hex, it works.


That is seriously one of the best jokes I've ever heard.

"Hey wizzup, what does this mean"
"It's hex"

Bobarkinator

2007-08-28 21:25:20

From: Wizzup?
It was more like a small joke.. Hex colors as you call it are just normal colors, it's still a number, and SCAR auto converts hex to dec. Try using a IntToStr with hex, it works.


So what about the "Result + hex"

From: The Claw
That is seriously one of the best jokes I've ever heard.

"Hey wizzup, what does this mean"
"It's hex"


Lol.