Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Loading Filenames into a Dynamic Array?

    I made a simple bit of code to randomly pick and display a picture every few minutes, for my windows desktop, as seen here:

    Code:
    function background()
    {
     with(Math)
     {
      var background = (abs(round(random()*10000)))
     }
     background = background % 2;
     background +=1;
     element.runtimeStyle.background = "url("+background+".jpg) fixed";
     setTimeout( "window.location.reload()", 300000 );
    }
    Now, that's all very well, but it's a bit inconvenient, since I have to number all my files 1,2,3,… and adjust the code everytime I aquire a new picture.

    It's been several years since I've done any type of programming, but is there a way I can load the files, for a directory (and possibly the sub-directories) into a Dynamic Array, and get the length of the Array, and how would I do it?

  • #2
    New Coder
    Join Date
    May 2007
    Location
    SF, CA
    Posts
    55
    Thanks
    0
    Thanked 4 Times in 4 Posts
    try something like

    Code:
    import java.io.*
    
    ...
    
    File dir = new File("images"); // Your image directory
    File[] files = dir.listFiles(); // You'll need to check to make sure the file object isn't a directory, see javadocs for java.io.File
    Also you can make another class that implements FilenameFilter or FileFilter and pass a filter into listFiles or list.

    hope this helps.

    semper fi...

  • #3
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, it's helped me a bit, I'm still very rusty, but it should take me long to get back into the swing of things.

  • #4
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dr2 zemmerzett?

    Hi Zem...
    Hey man since ur coding now maybe u can look at the players stats page on the mojo site and help us with the coding...We want to add buttons to increase or decrease the size of the gif but keep the win loss percentage aspect of the scripts...
    That is IF your the DR2 ZEM MASTER

  • #5
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Zemzerrett,

    Have you got any final solution. I want to implement a similar solution. i am creating a vista gadget in which in the flyout...i want to display some images stored on server and after that i want to display those images randomly.

    Can you give me the entire javascript if possible

    Thanks,
    Shreyas


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •