SRL Archive - Suggestions

{$include}


Feroc1ty

2011-03-22 20:30:33

make an {include} be optional, and {require} be like a required include, yaknow?

right now in my script i want to have an optional include (it's required but allowing it to be "optional" it runs and lets the user to choose weather he wants to download it or not, rather than forcing a download or not working at all) and if it's missing the script will ask the user if he wants to download it, depending on the answer script simply downloads the include or terminates, before using any of the functions required by the include.

Gu3st...

2011-03-22 20:35:29

I support this.

Nava2

2011-03-22 21:08:45

Use defines?

i luffs yeww

2011-03-22 21:10:07

{ifdef}?

Gu3st...

2011-03-22 21:15:47

From: Nava2
Use defines?
A built-in {$Require ./…} would still be nice :)

Feroc1ty

2011-03-22 22:23:06

what use does {IFDEF} do to me when the script doesn't even compile because if the include is missing script doesn't even compile to use those definitions…

i luffs yeww

2011-03-22 22:30:07

I think the reason you don't get answers a lot is because you compare things like our include to other language's include, when we treat our include as PHP's require.

What you want is to change our include to require, and add include, afaik.

Awkwardsaw

2011-03-22 23:34:35

From: Feroc1ty
what use does {IFDEF} do to me when the script doesn't even compile because if the include is missing script doesn't even compile to use those definitions…


if you wrap every function with {IFDEF} then it will compile, AFAIK

Dgby714

2011-03-22 23:50:24

With our current system his script will not compile if the included file is not found.
He cannot use defines to do this.
Read iluffyewws post above.

Nava2

2011-03-23 03:01:15

From: Dgby714
With our current system his script will not compile if the included file is not found.
He cannot use defines to do this.
Read iluffyewws post above.


Yes you can. :)

But its ugly, and doing what he is asking for is far from trivial. It would really be a matter of PS supporting it or not.. I personally find it trivial.

Dgby714

2011-03-23 03:08:58

Show me?

program _;
{$I IncludeWithTestProc} //He wants this to not raise a exception when file not found

procedure DownloadInclude();
begin
//....
end;

begin
{$IFNDEF IncludeSucceded} //This is defined inside of include
DownloadInclude();
{$ELSE}
Test();
{$ENDIF}
end.

Emaziz

2011-03-23 10:38:24

program _;
{$DEFINE IncludeSucceded} // Comment out this if you do NOT have include :p
{$IFDEF IncludeSucceded}
{$I IncludeWithTestProc} //He wants this to not raise a exception when file not found
{$ENDIF}

procedure DownloadInclude();
begin
//....
end;

begin
{$IFNDEF IncludeSucceded} //This is defined inside of include
DownloadInclude();
{$ELSE}
Test();
{$ENDIF}
end.

footballjds

2011-03-23 10:40:33

From: Emaziz
program _;
{$DEFINE IncludeSucceded} // Comment out this if you do NOT have include :p
{$IFDEF IncludeSucceded}
{$I IncludeWithTestProc} //He wants this to not raise a exception when file not found
{$ENDIF}

procedure DownloadInclude();
begin
//....
end;

begin
{$IFNDEF IncludeSucceded} //This is defined inside of include
DownloadInclude();
{$ELSE}
Test();
{$ENDIF}
end.


This works beautifully Emaziz, but it requires user input/editing. it sounds as if he's going for something dynamic. ;)

Feroc1ty

2011-03-23 11:56:59

From: Emaziz
program _;
{$DEFINE IncludeSucceded} // Comment out this if you do NOT have include :p
{$IFDEF IncludeSucceded}
{$I IncludeWithTestProc} //He wants this to not raise a exception when file not found
{$ENDIF}

procedure DownloadInclude();
begin
//....
end;

begin
{$IFNDEF IncludeSucceded} //This is defined inside of include
DownloadInclude();
{$ELSE}
Test();
{$ENDIF}
end.

You can look at my script in the public section, that does me no good as you can just comment out the include; I don't get why you people are trying to "help" me solve a non existant problem, I'm simply making a suggestion which would improve Simba.

Emaziz

2011-03-23 12:21:36

From: Dgby714
With our current system his script will not compile if the included file is not found.
He cannot use defines to do this.
Read iluffyewws post above.


From: Feroc1ty
what use does {IFDEF} do to me when the script doesn't even compile because if the include is missing script doesn't even compile to use those definitions…


I just showed that defines can be used?

Dgby714

2011-03-23 16:57:15

From: Emaziz
I just showed that defines can be used?


He wanted it to be done without a user having to change the script at all.

Wizzup?

2011-03-23 17:59:58

When do you want to include something that is not required?

footballjds

2011-03-23 18:05:38

From: Wizzup?
When do you want to include something that is not required?


I believe he wanted a script to compile, but not run. Unless it gets the include(via download or what not). imo a script lacking an include cannot compile.

Gu3st...

2011-03-23 18:06:20

From: Wizzup?
When do you want to include something that is not required?
I.E if you make something that doesn't require reflection, but if someone has it downloaded, it would use it

nielsie95

2011-03-23 18:16:41

I think it should be added :) Probably not using {$include} though?

footballjds

2011-03-23 18:17:26

From: nielsie95
I think it should be added :) Probably not using {$include} though?


something else maybe?

and i love how the person that started this thread is banned :p

HarryJames

2011-03-23 20:11:39

Yeah, I think he was banned in my SRL Member question thread, he started properly argueing with a few people :)

Not sure if it works in Simba, but can you not do something like this at the top?

Function FindAxe : forward;
Function FindAxe; forward;

Or something similar?

Dgby714

2011-03-23 20:17:08

From: HarryJames
Yeah, I think he was banned in my SRL Member question thread, he started properly argueing with a few people :)

Not sure if it works in Simba, but can you not do something like this at the top?

Function FindAxe : forward;
Function FindAxe; forward;

Or something similar?


That is for using a function(A) in a function(B) that requires function(B) also like -


function What: string; forward;

function TheName: string;
begin
Result := 'Something';
if (Random(2) = 1) then
Result := What;
end;

function What: string;
begin
Result := TheName + ' WhatTheF';
end;

HarryJames

2011-03-24 08:59:11

Ohh okay, thanks for that :)

You've actually helped me with odd bits of C++ that I was stuck on! <3<33

Ogre

2011-03-24 10:02:32

I don't see what you mean by an "optional include". How can an include be optional, either you need the functions in it or you don't.

I guess maybe if I had some OgreDebug.simba that was optional, then it would only do my fancy debug if that was there, but can't you just do a try..except..end around the functions that require an optional include? sorry I can't test anything I'm saying right now, g2g to school..

Gu3st...

2011-03-24 10:51:32

{$i SRL/SRL.scar}
{$optional Reflection/Reflection.simba}

procedure KillChickens;
{$IFDEF Reflection}
var
Chicken : TNPCArray;
{$ENDIF}
begin
{$IFDEF Reflection}
Chicken := FindNPCs('Chicken');
//...
Exit;
{$ENDIF}
FindColorTolerance(blah blah);
//...
end;

begin
SetupSRL;
{$IFDEF Reflection}
SetupReflection;
{$ENDIF}
KillChickens;
end.

Wizzup?

2011-03-24 11:05:14

Ok, so why not use
{$IFDEF REFLECTION}{$I reflection.simba}{$ENDIF}
as well?

Gu3st...

2011-03-24 11:11:19

From: Wizzup?
Ok, so why not use
{$IFDEF REFLECTION}{$I reflection.simba}{$ENDIF}
as well?
Because {$DEFINE Reflection} is inside Reflection.simba? :redface:

footballjds

2011-03-24 11:12:53

From: Zyt3x
{$i SRL/SRL.scar}
{$optional Reflection/Reflection.simba}

procedure KillChickens;
{$IFDEF Reflection}
var
Chicken : TNPCArray;
{$ENDIF}
begin
{$IFDEF Reflection}
Chicken := FindNPCs('Chicken');
//...
Exit;
{$ENDIF}
FindColorTolerance(blah blah);
//...
end;

begin
SetupSRL;
{$IFDEF Reflection}
SetupReflection;
{$ENDIF}
KillChickens;
end.


From: Wizzup?
Ok, so why not use
{$IFDEF REFLECTION}{$I reflection.simba}{$ENDIF}
as well?


the use of if def's throughout a script would become taxing.
therefore, i think the easiest solution would be as follows:

program killChickensColRef;
{reflection procedures include}
{color procedures include}

begin
FindChickens;
KillChickens;
end;
Now, what if the user doesn't have to change anything? But if the reflection includes are found it uses that, otherwise it uses the color include. thus in the script there doesn't have to be ifdef reflection then GetNPC's blah blah.
if i wrote a script and had a reflection include and a color include and name all the functions in each include the same(IE findChicken), then i could in my main script just call findChicken and not have to worry whether or not it's using col or ref.(sorry if this is extremely hard to follow, not feeling too well)

Gu3st...

2011-03-24 11:19:41

From: footballjds
program killChickensColRef;
{reflection procedures include}
{color procedures include}

begin
FindChickens;
KillChickens;
end;
Now, what if the user doesn't have to change anything? But if the reflection includes are found it uses that, otherwise it uses the color include. thus in the script there doesn't have to be ifdef reflection then GetNPC's blah blah.
if i wrote a script and had a reflection include and a color include and name all the functions in each include the same(IE findChicken), then i could in my main script just call findChicken and not have to worry whether or not it's using col or ref.(sorry if this is extremely hard to follow, not feeling too well)
I don't get it.. You want to do something like this?
{$optional Reflection/Reflection.simba}
{$IFDEF Reflection}
{$i RefStuff.simba}
{$ELSEIF}
{$i ColorStuff.simba}
{$ENDIF}

footballjds

2011-03-24 11:21:57

From: Zyt3x
I don't get it.. You want to do something like this?
{$optional Reflection/Reflection.simba}
{$IFDEF Reflection}
{$i RefStuff.simba}
{$ELSEIF}
{$i ColorStuff.simba}
{$ENDIF}


yes, I think we are on the same page. I will create a simba package and upload it into a .rar so i can be sure im properly explaining myself.

EDIT: example in .rar