This little ( started little any way ) will transfer a hash table to a text file and sort several different ways. Thanks to QuickStep for the " sorttxt " alias.
;Usage /htt HashTable WL/W FW/AW TextFile ( to omit $3 use a zero )
; WL = Word Length
; W = No Length
; FW = First Word
; AW = All Words
; Ex: /htt HashTable W --> Sorts HashTable alphabetically ( sent to Temp.txt ) <-- No data for HashTable
; Ex: /htt HashTable W FW --> Sorts HashTable alphabetically FirstWord ( sent to Temp.txt )
; Ex: /htt HashTable W FW TextFile --> Sorts HashTable alphabetically FirstWord ( sent to TextFile )
; Ex: /htt HashTable W 0 TextFile --> Sorts HashTable alphabetically ( sent to TextFile ) <-- No data for/used HashTable
; Ex: /htt HashTable W AW --> Sorts HashTable alphabetically " all words " ( sent to Temp.txt )
; EX: /htt HashTable W AW TextFile > Sorts HashTable alphabetically " all words " ( sent to TextFile )
; Ex: /htt HashTable WL --> Sorts HashTable " length of 1st word " ( sent to Temp.txt ) <-- No data for HashTable
; Ex: /htt HashTable WL FW --> Sorts HashTable WordLength " length of 1st word " ( sent to Temp.txt )
; Ex: /htt HashTable WL FW TextFile --> Sorts HashTable " length of 1st word " ( sent to TextFile )
; Ex: /htt HashTable WL 0 TextFile --> Sorts HashTable " length of 1st word " ( sent to TextFile ) <-- No data for/used HashTable
; Ex: /htt HashTable WL AW --> Sorts HashTable " length of all words " ( sent to Temp.txt )
; Ex: /htt HashTable WL AW TextFile --> Sorts HashTable " length of all words " ( sent to TextFile )
; It will check if the HashTable ( $1 ) exsist and if the TextFile ( $4 ) exsist it will let you know you can not use it.
; If the TextFile ( $4 ) does not exsist it will let you use it and will add " .txt " if you do not.
; If you try to use a FW/AW in the third position ( $3 ) and there is no data for the HashTable it will let you know.
;Usage /htt HashTable WL/W FW/AW TextFile ( to omit $3 use a zero )
; WL = Word Length
; W = No Length
; FW = First Word
; AW = All Words
;Usage /htt HashTable WL/W FW/AW TextFile ( to omit $3 use a zero )
; WL = Word Length
; W = No Length
; FW = First Word
; AW = All Words
; Ex: /htt HashTable W --> Sorts HashTable alphabetically ( sent to Temp.txt ) <-- No data for HashTable
; Ex: /htt HashTable W FW --> Sorts HashTable alphabetically FirstWord ( sent to Temp.txt )
; Ex: /htt HashTable W FW TextFile --> Sorts HashTable alphabetically FirstWord ( sent to TextFile )
; Ex: /htt HashTable W 0 TextFile --> Sorts HashTable alphabetically ( sent to TextFile ) <-- No data for/used HashTable
; Ex: /htt HashTable W AW --> Sorts HashTable alphabetically " all words " ( sent to Temp.txt )
; EX: /htt HashTable W AW TextFile > Sorts HashTable alphabetically " all words " ( sent to TextFile )
; Ex: /htt HashTable WL --> Sorts HashTable " length of 1st word " ( sent to Temp.txt ) <-- No data for HashTable
; Ex: /htt HashTable WL FW --> Sorts HashTable WordLength " length of 1st word " ( sent to Temp.txt )
; Ex: /htt HashTable WL FW TextFile --> Sorts HashTable " length of 1st word " ( sent to TextFile )
; Ex: /htt HashTable WL 0 TextFile --> Sorts HashTable " length of 1st word " ( sent to TextFile ) <-- No data for/used HashTable
; Ex: /htt HashTable WL AW --> Sorts HashTable " length of all words " ( sent to Temp.txt )
; Ex: /htt HashTable WL AW TextFile --> Sorts HashTable " length of all words " ( sent to TextFile )
; It will check if the HashTable ( $1 ) exsist and if the TextFile ( $4 ) exsist it will let you know you can not use it.
; If the TextFile ( $4 ) does not exsist it will let you use it and will add " .txt " if you do not.
; If you try to use a FW/AW in the third position ( $3 ) and there is no data for the HashTable it will let you know.
;Usage /htt HashTable WL/W FW/AW TextFile ( to omit $3 use a zero )
; WL = Word Length
; W = No Length
; FW = First Word
; AW = All Words
alias htt {
$iif(($4),$iif($right($4,4) == .txt, set %r $4, set %r $($4 $+ .txt)))
$iif(($isfile(%r)), echo 4 -a That text file already exsist.)
if (!$1) { echo 4 -a Please choose a Hash Table. | halt }
else {
set %temp $1
if (!$hget(%temp)) { echo 4 -a That Hash Table does not exsist. | halt }
else {
if (!$2) { echo 4 -a Please choose either WL ( length of first word ) or W ( no length ). | halt }
if ($2 = WL) {
if ((!$hget(%temp,1).data) && ($3)) { echo 4 -a There is no data stored for that Hash Table. | halt }
if (!$hget(%temp,1).data) {
write -c Temp.txt
var %t = 1
while (%t <= $hget(%temp,0).item) {
if ($len($hget(%temp,%t).item) <= 9) { write $iif((%r), %r, Temp.txt) $( 0 $+ $len($hget(%temp,%t).item)) $hget(%temp,%t).item }
if ($len($hget(%temp,%t).item) >= 10) { write $iif((%r), %r, Temp.txt) $len($hget(%temp,%t).item) $hget(%temp,%t).item }
inc %t
}
sorttxt $iif((%r), %r, Temp.txt)
unset %r | unset %temp
halt
}
if (($hget(%temp,1).data) && (!$3)) {
write -c Temp.txt
var %t = 1
while (%t <= $hget(%temp,0).item) {
while (%t <= $hget(%temp,0).data) {
if ($len($hget(%temp,%t).item) <= 9) { write $iif((%r), %r, Temp.txt) $( 0 $+ $len($hget(%temp,%t).item)) $hget(%temp,%t).item $hget(%temp,%t).data }
if ($len($hget(%temp,%t).item) >= 10) { write $iif((%r), %r, Temp.txt) $len($hget(%temp,%t).item) $hget(%temp,%t).item $hget(%temp,%t).data }
inc %t
}
sorttxt $iif((%r), %r, Temp.txt)
unset %r | unset %temp
halt
}
}
if (($hget(%temp,1).data) && ($3)) {
if ($3 = FW) {
write -c Temp.txt
var %t = 1
while (%t <= $hget(%temp,0).item) {
while (%t <= $hget(%temp,0).data) {
if ($len($hget(%temp,%t).item) <= 9) { write $iif((%r), %r, Temp.txt) $( 0 $+ $len($hget(%temp,%t).item)) $hget(%temp,%t).item $hget(%temp,%t).data }
if ($len($hget(%temp,%t).item) >= 10) { write $iif((%r), %r, Temp.txt) $len($hget(%temp,%t).item) $hget(%temp,%t).item $hget(%temp,%t).data }
inc %t
}
}
sorttxt $iif((%r), %r, Temp.txt)
unset %r | unset %temp
halt
}
if ($3 == AW) {
write -c Temp.txt
var %t = 1
while (%t <= $hget(%temp,0).item) {
while (%t <= $hget(%temp,0).data) {
write $iif((%r), %r, Temp.txt) $iif($calc($calc( $len($hget(%temp,%t).item + $hget(%temp,%t).data) - $( $regex($hget(%temp,%t).item,/s/g) - $regex($hget(%temp,%t).data,/s/g) - 1) ) -1 ) < 10, $( 0 $+ $calc($calc( $len($hget(%temp,%t).item + $hget(%temp,%t).data) - $( $regex($hget(%temp,%t).item,/s/g) - $regex($hget(%temp,%t).data,/s/g) - 1) ) -1 ) ), $calc($calc( $len($hget(%temp,%t).item + $hget(%temp,%t).data) - $( $regex($hget(%temp,%t).item,/s/g) - $regex($hget(%temp,%t).data,/s/g) - 1) ) -1 )) $hget(%temp,%t).item $hget(%temp,%t).data
inc %t
}
}
sorttxt $iif((%r), %r, Temp.txt)
unset %r | unset %temp
halt
}
}
}
if ($2 == W) {
if ((!$hget(%temp,1).data) && ($3)) { echo 4 -a There is no data stored for that Hash Table. | halt }
if (!$hget(%temp,1).data) {
write -c Temp.txt
var %t = 1
while (%t <= $hget(%temp,0).item) {
write $iif((%r), %r, Temp.txt) $hget(%temp,%t).item
inc %t
}
sorttxt $iif((%r), %r, Temp.txt)
unset %r | unset %temp
halt
}
if (($hget(%temp,1).data) && (!$3)) {
write -c Temp.txt
var %t = 1
while (%t <= $hget(%temp,0).item) {
while (%t <= $hget(%temp,0).data) {
write $iif((%r), %r, Temp.txt) $hget(%temp,%t).item $hget(%temp,%t).data
inc %t
}
}
sorttxt $iif((%r), %r, Temp.txt)
unset %r | unset %temp
halt
}
if (($hget(%temp,1).data) && ($3)) {
if ($3 = FW) {
write -c Temp.txt
var %t = 1
while (%t <= $hget(%temp,0).item) {
while (%t <= $hget(%temp,0).data) {
if ($len($hget(%temp,%t).item) <= 9) { write $iif((%r), %r, Temp.txt) $( 0 $+ $len($hget(%temp,%t).item)) $hget(%temp,%t).item $hget(%temp,%t).data }
if ($len($hget(%temp,%t).item) >= 10) { write $iif((%r), %r, Temp.txt) $len($hget(%temp,%t).item) $hget(%temp,%t).item $hget(%temp,%t).data }
inc %t
}
}
sorttxt $iif((%r), %r, Temp.txt)
unset %r | unset %temp
halt
}
if ($3 == AW) {
write -c Temp.txt
var %t = 1
while (%t <= $hget(%temp,0).item) {
while (%t <= $hget(%temp,0).data) {
write $iif((%r), %r, Temp.txt) $iif($calc($calc( $len($hget(%temp,%t).item + $hget(%temp,%t).data) - $( $regex($hget(%temp,%t).item,/s/g) - $regex($hget(%temp,%t).data,/s/g) - 1) ) -1 ) < 10, $( 0 $+ $calc($calc( $len($hget(%temp,%t).item + $hget(%temp,%t).data) - $( $regex($hget(%temp,%t).item,/s/g) - $regex($hget(%temp,%t).data,/s/g) - 1) ) -1 ) ), $calc($calc( $len($hget(%temp,%t).item + $hget(%temp,%t).data) - $( $regex($hget(%temp,%t).item,/s/g) - $regex($hget(%temp,%t).data,/s/g) - 1) ) -1 )) $hget(%temp,%t).item $hget(%temp,%t).data
inc %t
}
}
sorttxt $iif((%r), %r, Temp.txt)
unset %r | unset %temp
halt
}
}
}
}
}
}
;Usage: /sorttxt <file>
;Sorts a text file the propper (and fastest) way
;From QuickStep
alias sorttxt $iif($isfile($+(",$$1-,")),filter -affc $str($+(",$1-,",$chr(32)),2))