Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
11ebc14c
Commit
11ebc14c
authored
5 years ago
by
nightfox
Browse files
Options
Downloads
Patches
Plain Diff
sort_file.js is probably of limited use.
parent
5f8437c5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/sort_file.js
+0
-94
0 additions, 94 deletions
exec/sort_file.js
with
0 additions
and
94 deletions
exec/sort_file.js
deleted
100644 → 0
+
0
−
94
View file @
5f8437c5
// $Id$
/* 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:
* jsexec 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).
*/
load
(
"
sbbsdefs.js
"
);
if
(
argc
<
2
)
{
write
(
"
\r\n
Usage: sort_file.js <inputFilename> <outputFilename> [convertToLowercase]
\r\n\r\n
"
);
exit
(
1
);
}
write
(
"
\r\n
"
);
var
inputFilename
=
argv
[
0
];
var
outputFilename
=
argv
[
1
];
var
convertToLowercase
=
false
;
if
(
argc
>=
3
)
convertToLowercase
=
(
argv
[
2
].
toLowerCase
()
==
"
true
"
);
write
(
"
Input filename:
"
+
inputFilename
+
"
\r\n
"
);
write
(
"
Output filename:
"
+
outputFilename
+
"
\r\n
"
);
write
(
"
Convert to lowercase:
"
+
convertToLowercase
+
"
\r\n
"
);
write
(
"
Sorting...
\r\n
"
);
var
succeeded
=
sortFile
(
inputFilename
,
outputFilename
,
convertToLowercase
);
if
(
succeeded
)
write
(
"
Sort successful.
\r\n
"
);
else
write
(
"
Sort failed!
\r\n
"
);
write
(
"
\r\n
"
);
//////////////////////////////////
// Functions
function
sortFile
(
pInputFilename
,
pOutputFilename
,
pToLowercase
)
{
var
succeeded
=
true
;
var
inFile
=
new
File
(
pInputFilename
);
var
fileLines
=
[];
if
(
inFile
.
open
(
"
r
"
))
{
var
dupeCheckObj
=
{};
var
fileLine
;
while
(
!
inFile
.
eof
)
{
// Read the next line from the file.
fileLine
=
inFile
.
readln
(
2048
);
// fileLine should be a string, but I've seen some cases
// where for some reason it isn't. If it's not a string,
// then continue onto the next line.
if
(
typeof
(
fileLine
)
==
"
string
"
)
{
if
(
pToLowercase
)
fileLine
=
fileLine
.
toLowerCase
();
if
(
!
dupeCheckObj
.
hasOwnProperty
(
fileLine
))
{
fileLines
.
push
(
fileLine
);
dupeCheckObj
[
fileLine
]
=
true
;
}
}
}
inFile
.
close
();
}
else
succeeded
=
false
;
if
(
succeeded
)
{
fileLines
.
sort
();
var
outFile
=
new
File
(
pOutputFilename
);
if
(
outFile
.
open
(
"
w
"
))
{
for
(
var
i
=
0
;
i
<
fileLines
.
length
;
++
i
)
outFile
.
writeln
(
fileLines
[
i
]);
outFile
.
close
();
}
else
succeeded
=
false
;
}
return
succeeded
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment