SRL Archive - SRL Suggestions

Boolean var, for smart, SMART_Use?


Awkwardsaw

2009-09-24 07:27:22

instead of commenting out / uncommenting the SMART Misc include if you want to use it or not, why not just make a Boolean variable for it?

SMART Vars in global.scar:

var
Smart_Members, Smart_Signed, Smart_SuperDetail, Smart_Use: Boolean;

and SMART Setup in SRL.Scar:

  Smart_Server := Smart_Server;
Smart_Members:= Smart_Members;
Smart_Signed := Smart_Signed;
Smart_Use := true;
Smart_SuperDetail := Smart_SuperDetail;
{$IFDEF SRL_SMART}
if Smart_Use then begin
{ ReLoad := False;
s := SmartLastSettings;
if High(s) <> 4 then SetLength(s, 5);
try
SmartGetColor(0, 0);
Reload := False;
except
Reload := True;
end;
if Reload then
begin
writeln('unopened');
if (Smart_Server = 0) then
begin
Smart_Server := RandomWorld(Smart_Members, False);
Smart_Signed := True;
Smart_SuperDetail := False;
end;
end else
begin
vv := [Smart_Server, Smart_Members, Smart_Signed, Smart_SuperDetail];
for i := 0 to 3 do
if not (s[i] = vv[i]) then
begin
ReLoad := True;
Break;
end;
end;
if ReLoad then
begin
Writeln('SMART Initialized.' + #10 + 'Loaded: Server ' + IntToStr(Smart_Server) + ', Members: ' + BoolToStr(Smart_Members)
+ ', Signed: ' + BoolToStr(Smart_Signed) + ', Super Detail: ' + BoolToStr(Smart_SuperDetail) + '.');
SmartSetupEx(Smart_Server, Smart_Members, Smart_Signed, Smart_SuperDetail);
end; }
if (Smart_Server = 0) then
begin
Smart_Server := RandomWorld(Smart_Members, False);
Smart_Signed := True;
Smart_SuperDetail := False;
end;
Writeln('SMART Initialized.' + #10 + 'Loaded: Server ' + IntToStr(Smart_Server) + ', Members: ' + BoolToStr(Smart_Members)
+ ', Signed: ' + BoolToStr(Smart_Signed) + ', Super Detail: ' + BoolToStr(Smart_SuperDetail) + '.');
SmartSetupEx(Smart_Server, Smart_Members, Smart_Signed, Smart_SuperDetail);
SetTargetDC(SmartGetDC);
repeat
Wait(100);
if (GetTimeRunning - t) > 120000 then
Break;
until(RSReady);
end;
{$ENDIF}

and yes, All that is man's form question gave me this idea :)

then in your script setup, you can have

const
UseSmart = false;
Smartworld = 0; //if UseSmart = true, fill out
members = false; //if UseSmart = true, fill out

All that is man

2009-09-24 08:02:48

From: Awkwardsaw

Smart_Use := true;

Wouldn't you want

Smart_Use := Smart_Use;
Thats the only way I can get it working

Awkwardsaw

2009-09-24 08:04:53

From: All that is man
Wouldn't you want

Smart_Use := Smart_Use;
Thats the only way I can get it working


your most likley right, :) i just thought that it should be set to true as default, instead of having to be set to true

Daniel

2009-09-24 10:39:55

But SMART.scar over-writes all the standard functions/procedures for SMART use.. So, since those functions are only valid in the SMART client, there'd be no use?

marpis

2009-09-24 13:21:52

You can activate SMART with 1 line already

{.include srl/srl/misc/smart.scar}
And if smart.scar is included, smart must be used, won't work otherwise.

Awkwardsaw

2009-09-25 01:53:44

From: marpis
You can activate SMART with 1 line already

{.include srl/srl/misc/smart.scar}
And if smart.scar is included, smart must be used, won't work otherwise.


the whole point of this is to remove the need to uncomment/ comment the

{.include srl/srl/misc/smart.scar}

wait, so if its included, it will totally screw over the

 if SMART_Use then begin 

and pretend that it isnt there, but every thing else still goes on?

senrath

2009-09-25 01:57:26

Yeah, if smart.scar is included, you HAVE to use SMART, as it overrides most every basic function.

Nava2

2009-09-25 03:29:09

From: senrath
Yeah, if smart.scar is included, you HAVE to use SMART, as it overrides most every basic function.


s/almost//

marpis

2009-09-25 15:05:18

From: Awkwardsaw
the whole point of this is to remove the need to uncomment/ comment the

{.include srl/srl/misc/smart.scar}

wait, so if its included, it will totally screw over the

 if SMART_Use then begin 

and pretend that it isnt there, but every thing else still goes on?


check smart.scar file and see what all functions it screws…

Bixby Sayz

2009-09-25 15:59:17

I tried to something exactly like this with a DEFINE, Ie:

{$DEFINE UseSmart}

{$IFDEF UseSmart}{.include srl/srl/misc/smart.scar}{$ENDIF}

...

{$IFDEF SRL_Smart}
const
SmartWorld = 0; // and so on
{$ENDIF}

Then all you have to do is comment/uncomment the one define at the top of the script.

But I ran into some weird problems with the way SCAR itself handles the processing of IFDEF that made it unsuitable for using with the includes.

And you are still commenting/uncommented one line (or in your example setting a bool var) at the start of your script anyway, so really you are gaining nothing.