Vibe Recursion

Amish

07-07-2006 22:37:12

Right I need to use a function for recusion, but I cant make a function in the vibe language so i have to make it in Javascript and use the <? ?> in the function. Can I pass a argument from the function to the vibe language and how can i run the javascript function from the vibe language?

siit

08-07-2006 19:22:03

humm, well you can output javascript using the print() command. for example

print("var i=0;");
print("document.write(i)");

so.. for example you can create a function

print("function myJavaScriptFunction()");
print("{");
print("alert(\'hello\');");
print("}");

and then call the function this way

print("myJavaScriptFunction();");

that should do it.

hmm, maybe I should see if I can learn the vibe script language to handle functions, it shouldn't be impossible but don't except it soon thought )

Amish

09-07-2006 00:25:45

Nope dont work. Im trying to use recursion to make the songs recursive in folders when you press the green "+" sign.

but its proving difficu with no functions in vibe.

siit

09-07-2006 00:54:30

hmm, well, to be honest I'd think that function support in the Vibe Script Language is required for this case. Haven't thought much about it much before now and I left it out due to the reason that I didn't think I'd come to a situation where I needed it to develop skins.

Although for recursion I'd say the best way is to implement function support in the script language. I'd add it to the to-do list )

Meanwhile, if I come up with another idea I'll let you know..

Amish

09-07-2006 13:13:41

Yah, so hop to it. D

siit

10-07-2006 00:46:38

haha... jeez man, it's vacation time you know! well well D

Bulo

22-07-2006 17:36:38

Hello!

I'm a very new user of VibeStreamer (in fact I just downloaded the software yesterday).
I was a bit (very little bit) disappointed to see that it was not possible to add a folder containing only subfolders in the playlist.
But the good news is that I have a solution. I modified the standard skin to allow recursion on subfolders.

I just had to add few lines in the "process_addfolder.vibe" file.
If you are interested, just let me know. I can give you my code.

Amish

22-07-2006 18:28:56

Yes please. Does this work for an unlimited amount of folders in folders?

But post anyways.

Bulo

22-07-2006 22:39:49

I suppose there is a limit because I use an array to store the " recursion path". But it works fine on my system ... just test it and let me know.

So here is the code (it's a copy paste of my file 'process_addfolder.vibe')

<script>
<?
var numMP3Files = 0;
var dirs = array();

array_push(&dirs, request_querystring("id"));

while (count(&dirs) > 0) {
var dir = dirs[0];
array_remove(&dirs, 0);


// get files from the current dir
var files = get_files(dir);
var numFiles = count(&files);
//print("alert('files " + numFiles + "');");
var i = 0;
while ( i<numFiles )
{
var file = &files;

if ( file.MIMEType=="audio/mpeg" )
{
numMP3Files++;

print("parent.add_track('" + str_jsafe(file.VirtualPath) + "');");
}

i++;
}

// get the subdirectories
var subDirs = get_directories(dir);
var numDirs = count(&subDirs);
i = 0;
//print("alert('subdirs " + numDirs + " of " + dir + "');");
while ( i<numDirs )
{
var subDir = dir + "/" + &subDirs.Name;
//print("alert('subdir[" + i + "] " + subDir + "');");

array_push(&dirs, subDir);

i++;
}
}


if ( numMP3Files==0 ) {
print("alert('No audio files could be found in the folder.');");
}

?>

parent.g_bThreadFrameIsBusy = false;

</script>

g8trtim

09-08-2006 00:43:39

nice work... successfully added 23 folders within one folder... thanks

prescan7000

06-08-2009 10:20:20

I know this is an old topic but...

The script above isn't recursive to me... It looks like it is not going to work when I have a folder like this

database/subdir1/subdir2/subdir3

I am a php programmer, but there is no function-support in the vibe-language and that is what it makes so hard to make anything recursive.

What I would like to have is an array with all files in the database, is this possible with the VIBE-language? I am getting stucked with my loops...

Kind Regards,
Tim