• exec/sort_file.js

    From nightfox@VERT to CVS commit on Friday, May 24, 2019 21:03:37
    exec sort_file.js NONE 1.1
    Update of /cvsroot/sbbs/exec
    In directory cvs:/tmp/cvs-serv6840

    Added Files:
    sort_file.js
    Log Message:
    This is a script that can sort a file. This script is meant to be run with jsexec (on the OS command prompt, not via the Synchronet terminal server). One purpose of this script is to sort dictionary files when they're created or when words are added to existing dictionary files.

    The command-line syntax of this script is:
    sexec sort_file.js <inputFilename> <outputFilename> [convertToLowercase]
    Where <inputFilename> is the name of the input file and <outputFilename> is the name of the output file (the sorted input). convertToLowercase is optional, and specifies whether or not to convert all entries in the file to lower-case (which is required for case-insensitive word matching via SlyEdit, for instance). The values for convertToLowercase can be true or false (really, anything besides true will be interpreted as false).

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From nightfox@VERT to CVS commit on Friday, May 24, 2019 22:40:43
    exec sort_file.js 1.1 1.2
    Update of /cvsroot/sbbs/exec
    In directory cvs:/tmp/cvs-serv19900

    Modified Files:
    sort_file.js
    Log Message:
    Don't allow duplicates in the sorted output

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Digital Man@VERT to nightfox on Friday, May 24, 2019 23:45:02
    Re: exec/sort_file.js
    By: nightfox to CVS commit on Fri May 24 2019 09:03 pm

    exec sort_file.js NONE 1.1
    Update of /cvsroot/sbbs/exec
    In directory cvs:/tmp/cvs-serv6840

    Added Files:
    sort_file.js
    Log Message:
    This is a script that can sort a file. This script is meant to be run with jsexec (on the OS command prompt, not via the Synchronet terminal server). One purpose of this script is to sort dictionary files when they're created or when words are added to existing dictionary files.

    The command-line syntax of this script is:
    sexec sort_file.js <inputFilename> <outputFilename> [convertToLowercase] Where <inputFilename> is the name of the input file and <outputFilename> is the name of the output file (the sorted input). convertToLowercase is optional, and specifies whether or not to convert all entries in the file to lower-case (which is required for case-insensitive word matching via SlyEdit, for instance). The values for convertToLowercase can be true or false (really, anything besides true will be interpreted as false).

    Some questions about this script:
    - what does it do that the common 'sort' command cannot?
    - why not use the File.readAll() method?

    The script seems like the kind of thing that, if really needed, could be written in about 5 lines of code (JS) and it'd be more flexible if it read from stdin and wrote to stdout - like, the standard sort commands.

    digital man

    Synchronet "Real Fact" #41:
    Synchronet's cross-platform library is called XPDEV (named before Windows XP). Norco, CA WX: 56.1øF, 80.0% humidity, 1 mph SE wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Digital Man@VERT to nightfox on Friday, May 24, 2019 23:46:57
    Re: exec/sort_file.js
    By: nightfox to CVS commit on Fri May 24 2019 10:40 pm

    exec sort_file.js 1.1 1.2
    Update of /cvsroot/sbbs/exec
    In directory cvs:/tmp/cvs-serv19900

    Modified Files:
    sort_file.js
    Log Message:
    Don't allow duplicates in the sorted output

    There's a common utility/command for this too, it's 'uniq' (or sort -u).

    digital man

    This Is Spinal Tap quote #20:
    Well, I'm sure I'd feel much worse if I weren't under such heavy sedation. Norco, CA WX: 56.1øF, 80.0% humidity, 1 mph SE wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From nightfox@VERT to CVS commit on Saturday, May 25, 2019 12:54:16
    exec sort_file.js 1.2 NONE
    Update of /cvsroot/sbbs/exec
    In directory cvs:/tmp/cvs-serv11435

    Removed Files:
    sort_file.js
    Log Message:
    sort_file.js is probably of limited use.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Nightfox@VERT/DIGDIST to Digital Man on Saturday, May 25, 2019 12:52:08
    Re: exec/sort_file.js
    By: Digital Man to nightfox on Fri May 24 2019 11:46 pm

    Modified Files:
    sort_file.js
    Log Message:
    Don't allow duplicates in the sorted output

    There's a common utility/command for this too, it's 'uniq' (or sort -u).

    I'm running my BBS in Windows 7, and it doesn't seem to have a uniq utility. Also, I looked at the help for sort, and I don't see a -u (or /u) option.

    This is the help output of sort that its shows me:

    SORT [/R] [/+n] [/M kilobytes] [/L locale] [/REC recordbytes]
    [[drive1:][path1]filename1] [/T [drive2:][path2]]
    [/O [drive3:][path3]filename3]
    /+n Specifies the character number, n, to
    begin each comparison. /+3 indicates that
    each comparison should begin at the 3rd
    character in each line. Lines with fewer
    than n characters collate before other lines.
    By default comparisons start at the first
    character in each line.
    /L[OCALE] locale Overrides the system default locale with
    the specified one. The ""C"" locale yields
    the fastest collating sequence and is
    currently the only alternative. The sort
    is always case insensitive.
    /M[EMORY] kilobytes Specifies amount of main memory to use for
    the sort, in kilobytes. The memory size is
    always constrained to be a minimum of 160
    kilobytes. If the memory size is specified
    the exact amount will be used for the sort,
    regardless of how much main memory is
    available.

    The best performance is usually achieved by
    not specifying a memory size. By default the
    sort will be done with one pass (no temporary
    file) if it fits in the default maximum
    memory size, otherwise the sort will be done
    in two passes (with the partially sorted data
    being stored in a temporary file) such that
    the amounts of memory used for both the sort
    and merge passes are equal. The default
    maximum memory size is 90% of available main
    memory if both the input and output are
    files, and 45% of main memory otherwise.
    /REC[ORD_MAXIMUM] characters Specifies the maximum number of characters
    in a record (default 4096, maximum 65535).
    /R[EVERSE] Reverses the sort order; that is,
    sorts Z to A, then 9 to 0.
    [drive1:][path1]filename1 Specifies the file to be sorted. If not
    specified, the standard input is sorted.
    Specifying the input file is faster than
    redirecting the same file as standard input.
    /T[EMPORARY]
    [drive2:][path2] Specifies the path of the directory to hold
    the sort's working storage, in case the data
    does not fit in main memory. The default is
    to use the system temporary directory.
    /O[UTPUT]
    [drive3:][path3]filename3 Specifies the file where the sorted input is
    to be stored. If not specified, the data is
    written to the standard output. Specifying
    the output file is faster than redirecting
    standard output to the same file.

    ---
    þ Synchronet þ Digital Distortion: digitaldistortionbbs.com
  • From Digital Man@VERT to Nightfox on Saturday, May 25, 2019 14:04:23
    Re: exec/sort_file.js
    By: Nightfox to Digital Man on Sat May 25 2019 12:52 pm

    Re: exec/sort_file.js
    By: Digital Man to nightfox on Fri May 24 2019 11:46 pm

    Modified Files:
    sort_file.js
    Log Message:
    Don't allow duplicates in the sorted output

    There's a common utility/command for this too, it's 'uniq' (or sort -u).

    I'm running my BBS in Windows 7, and it doesn't seem to have a uniq utility. Also, I looked at the help for sort, and I don't see a -u (or /u) option.

    The Microsoft version of many *nix utilities have limited options. I recommend installing https://sourceforge.net/projects/unxutils and you'll get a lot more sort options as well full-feature *grep flavors and much more:

    Usage: \bin\unixutils\usr\local\wbin\sort [OPTION]... [FILE]...
    Write sorted concatenation of all FILE(s) to standard output.

    +POS1 [-POS2] start a key at POS1, end it *before* POS2 (obsolescent)
    field numbers and character offsets are numbered
    starting with zero (contrast with the -k option)
    -b ignore leading blanks in sort fields or keys
    -c check if given files already sorted, do not sort
    -d consider only [a-zA-Z0-9 ] characters in keys
    -f fold lower case to upper case characters in keys
    -g compare according to general numerical value, imply -b
    -i consider only [\040-\0176] characters in keys
    -k POS1[,POS2] start a key at POS1, end it *at* POS2
    field numbers and character offsets are numbered
    starting with one (contrast with zero-based +POS form)
    -m merge already sorted files, do not sort
    -M compare (unknown) < `JAN' < ... < `DEC', imply -b
    -n compare according to string numerical value, imply -b
    -o FILE write result on FILE instead of standard output
    -r reverse the result of comparisons
    -s stabilize sort by disabling last resort comparison
    -t SEP use SEParator instead of non- to whitespace transition
    -T DIRECTORY use DIRECTORY for temporary files, not $TMPDIR or /tmp
    -u with -c, check for strict ordering;
    with -m, only output the first of an equal sequence
    -z end lines with 0 byte, not newline, for find -print0
    --help display this help and exit
    --version output version information and exit

    digital man

    This Is Spinal Tap quote #40:
    Morty the Mime: Come on, don't talk back, mime is money, come on, move it. Norco, CA WX: 68.7øF, 59.0% humidity, 4 mph W wind, 0.00 inches rain/24hrs
    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net