Author Topic: exec all files? "exec("./*.cs");"  (Read 1004 times)

Is it possible to does this? I want an easy way of exec-ing all my .cs files.
« Last Edit: June 07, 2011, 10:05:56 PM by tyler0 »

Quote
   %file = findFirstFile("Add-Ons/Addon_name/*.cs");
   while(strLen(%file) > 0) {
      exec(%file);
      %file = findNextFile("Add-Ons/Addon_name/*.cs");
   }

I'm pretty sure there's a slightly shorter way, but this should work.

From my File I/O tutorial:

Code: [Select]
function loadClientAddons()
{
for(%i = findFirstFile("Add-Ons/*/client.cs"); %i !$= ""; %i = findNextFile("Add-Ons/*/client.cs"))
{
echo("Loading: "@strReplace(strReplace(%i, "/client.cs", ""), "Add-Ons/",""));
exec(%i);
}
}
function loadServerAddons()
{
for(%i = findFirstFile("Add-Ons/*/server.cs");%i!$="";%i=findNextFile("Add-Ons/*/server.cs"))
{
echo("Loading: "@strReplace(strReplace(%i, "/server.cs",""), "Add-Ons/", ""));
exec(%i);
}
}

From my File I/O tutorial:

-snip-

Ah, that's what I was thinking, but I didn't feel like opening the game to check what returns when there's no more files so I could get the check part.

From my File I/O tutorial:

Code: [Select]
function loadClientAddons()
{
for(%i = findFirstFile("Add-Ons/*/client.cs"); %i !$= ""; %i = findNextFile("Add-Ons/*/client.cs"))
{
echo("Loading: "@strReplace(strReplace(%i, "/client.cs", ""), "Add-Ons/",""));
exec(%i);
}
}
function loadServerAddons()
{
for(%i = findFirstFile("Add-Ons/*/server.cs");%i!$="";%i=findNextFile("Add-Ons/*/server.cs"))
{
echo("Loading: "@strReplace(strReplace(%i, "/server.cs",""), "Add-Ons/", ""));
exec(%i);
}
}

yea this could be helpful in the future. Thanks.


I'm pretty sure there's a slightly shorter way, but this should work.

You gave me exactly what i needed. Thanks

yea this could be helpful in the future. Thanks.


You gave me exactly what i needed. Thanks

His way was the shorter way I was thinking of, actually. :panda:

Like this is a bit better:
Code: [Select]
for(%file=findFirstFile("Add-Ons/*/server.cs");isFile(%file);%file=findNextFile("Add-Ons/*/server.cs"))