• Random Files

    From Bill McGarrity@1:229/2 to Thomas Bampi on Wednesday, April 18, 2018 13:45:00
    From: bill.mcgarrity@1:266/404.remove-111j-this

    To: Thomas Bampi
    Thomas Bampi wrote to All on 04-18-18 11:03 <=-

    Hi All! can you tell me a JS script that can take me in random files
    and copy them in a specific file?
    Example: I have files that are called logo.1, logo.2, logo.3, logo.4
    etc ... the script randomly takes one of these files and copies it as logo.ans

    The logon.js will already do that for you. Just name your .asc files random1.asc, random2.asc and so on. Instaying with the 8.3 standard, you can make 99 of them.


    --

    Bill

    Telnet: tequilamockingbirdonline.net
    Web: bbs.tequilamockingbirdonline.net
    FTP: ftp.tequilamockingbirdonline.net:2121
    IRC: irc.tequilamockingbirdonline.net Ports: 6661-6670 SSL: +6697
    Radio: radio.tequilamockingbirdonline.net:8010/live


    ... Look Twice... Save a Life!!! Motorcycles are Everywhere!!!
    --- MultiMail/Win32 v0.50
    * Origin: TequilaMockingbird Online - Toms River, NJ (1:266/404)
    --- Synchronet 3.17a-Win32 NewsLink 1.108
    * Vertrauen - Riverside County, California - telnet://vert.synchro.net

    --- SoupGate-Win32 v1.05
    * Origin: www.darkrealms.ca (1:229/2)
  • From Digital Man@1:229/2 to All on Wednesday, April 18, 2018 14:36:32
    From: digital.man@vert.synchro.net.remove-shk-this

    To: Thomas Bampi
    Re: Random Files
    By: Thomas Bampi to All on Wed Apr 18 2018 11:03 am

    Hi All! can you tell me a JS script that can take me in random files and copy them in a specific file?
    Example: I have files that are called logo.1, logo.2, logo.3, logo.4 etc ... the script randomly takes one of these files and copies it as logo.ans

    This question is best asked in one of the Synchronet Programming related message areas, but here's a short example in JS:

    file_copy("logo." + random(4), "logo.ans");

    There's an even better example in exec/logon.js (search for "random").

    digital man

    Synchronet "Real Fact" #61:
    How to get Synchronet technical support: http://wiki.synchro.net/howto:support Norco, CA WX: 73.0øF, 30.0% humidity, 15 mph ENE wind, 0.00 inches rain/24hrs --- Synchronet 3.17a-Win32 NewsLink 1.108
    * Vertrauen - Riverside County, California - telnet://vert.synchro.net

    --- SoupGate-Win32 v1.05
    * Origin: www.darkrealms.ca (1:229/2)
  • From poindexter FORTRAN@1:229/2 to All on Wednesday, April 18, 2018 18:41:32
    From: poindexter.fortran@REALITY.remove-35o-this

    To: Digital Man
    Re: Random Files
    By: Digital Man to Thomas Bampi on Wed Apr 18 2018 02:36 pm

    There's an even better example in exec/logon.js (search for "random").

    I was hoping for an algorithm that would pull a random line out of a text file, but then I broke up my text file into dozens of files with one line each.

    ---
    þ Synchronet þ realitycheckBBS -- http://realitycheckBBS.org
    --- Synchronet 3.17a-Win32 NewsLink 1.108
    * Vertrauen - Riverside County, California - telnet://vert.synchro.net

    --- SoupGate-Win32 v1.05
    * Origin: www.darkrealms.ca (1:229/2)
  • From Digital Man@1:229/2 to All on Wednesday, April 18, 2018 22:49:26
    From: digital.man@vert.synchro.net.remove-a4x-this

    To: poindexter FORTRAN
    Re: Random Files
    By: poindexter FORTRAN to Digital Man on Wed Apr 18 2018 06:41 pm

    Re: Random Files
    By: Digital Man to Thomas Bampi on Wed Apr 18 2018 02:36 pm

    There's an even better example in exec/logon.js (search for "random").

    I was hoping for an algorithm that would pull a random line out of a text file, but then I broke up my text file into dozens of files with one line each.

    Pulling a random line is pretty easy too:

    var f = new File(fname);
    if(!f.open("r")) {
    alert("Error opening " + fname);
    exit();
    }

    var list = f.readAll();
    f.close();
    var i = random(list.length);

    var line = list[i]; // line is now a randomly chosen line from the file

    digital man

    This Is Spinal Tap quote #17:
    David St. Hubbins: It's such a fine line between stupid, and uh... and clever. Norco, CA WX: 53.0øF, 70.0% humidity, 5 mph E wind, 0.00 inches rain/24hrs
    --- Synchronet 3.17a-Win32 NewsLink 1.108
    * Vertrauen - Riverside County, California - telnet://vert.synchro.net

    --- SoupGate-Win32 v1.05
    * Origin: www.darkrealms.ca (1:229/2)
  • From echicken@1:229/2 to All on Thursday, April 19, 2018 11:35:58
    From: echicken@ECBBS.remove-gza-this

    To: poindexter FORTRAN
    Re: Random Files
    By: poindexter FORTRAN to Digital Man on Wed Apr 18 2018 18:41:32

    I was hoping for an algorithm that would pull a random line out of a text file, but then I broke up my text file into dozens of files with one line each.

    var f = new File('lines');
    f.open('r');
    var lines = f.readAll();
    f.close();
    var line = lines[Math.floor(Math.random() * lines.length)];

    Something like that ort to work.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-273-7230


    ---
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
    --- Synchronet 3.17a-Win32 NewsLink 1.108
    * Vertrauen - Riverside County, California - telnet://vert.synchro.net

    --- SoupGate-Win32 v1.05
    * Origin: www.darkrealms.ca (1:229/2)
  • From poindexter FORTRAN@1:229/2 to All on Thursday, April 19, 2018 11:33:27
    From: poindexter.fortran@REALITY.remove-bz5-this

    To: Digital Man
    Re: Random Files
    By: Digital Man to poindexter FORTRAN on Wed Apr 18 2018 10:49 pm

    Pulling a random line is pretty easy too:

    Easy for you! :)

    Thanks a lot -- this will clean up my install greatly and let me add lines much more easily than creating a new file each time I add a line.

    ---
    þ Synchronet þ realitycheckBBS -- http://realitycheckBBS.org
    --- Synchronet 3.17a-Win32 NewsLink 1.108
    * Vertrauen - Riverside County, California - telnet://vert.synchro.net

    --- SoupGate-Win32 v1.05
    * Origin: www.darkrealms.ca (1:229/2)