From: Janilabo
No problem, mate!
By the way, I wrote a custom little function which doesn't include the file extension to the result..
It also returns as "Untitled" when script hasn't been saved.
Check this out:
function ScriptName: string;
var
p, o: Integer;
begin
Result := ScriptFile;
case (Result = '') of
False:
if (Pos('.', Result) > 0) then
begin
o := 1;
repeat
p := PosEx('.', Result, o);
if (p > 0) then
o := (p + 1);
until (p = 0);
Result := Copy(Result, 1, (o - 2));
end;
True: Result := 'Untitled';
end;
end;
begin
ClearDebug;
WriteLn(ScriptName);
end.
I know usually it's compiler dependent as to when Switch statements are more efficient than if/elseif statements, but in this case, wouldn't an if/else be more efficient?
Also, considering differing naming standards, can scripts ever have an extension outside of .simba? As it stands, if someone chose to name their script Fighter.V2.simba, or Fighter.Roaches.simba this method would only grab the "Fighter" portion of the name. Absolutely feel free to correct any mistakes I have in assumptions or concepts, but wouldn't an approach like this cover more scenarios then:
function ScriptName: string;
var
p, o: Integer;
lower: String;
begin
Result := ScriptFile;
if(Result <> '')then
begin
lower:= Lowercase(Result);
if (Pos('.simba', lower) > 0) then
begin
o := 1;
repeat
p := PosEx('.simba', lower, o);
if (p > 0) then
o := (p + 1);
until (p = 0);
Result := Copy(Result, 1, (o - 2));
end;
end else
Result := 'Untitled';
end;
Edit: Would ScriptName be in some other include besides srl.simba by chance?