click
here for more groovy stuff like this
func BubbleSort(ByRef
$bs_array)
for
$i = uBound(
$bs_array)-1 to 1 step -1
for
$j = 2 to
$i if
$bs_array[
$j-1] >
$bs_array[
$j] then
$temp =
$bs_array[
$j-1]
$bs_array[
$j-1] =
$bs_array[
$j]
$bs_array[
$j] =
$temp endif
next
next
return
$bs_arrayendfunc
func InsertionSort(ByRef
$is_array)
for
$i = 1 to uBound(
$is_array)-1
$index =
$is_array[
$i]
$j =
$i while
$j > 1 and
$is_array[
$j-1] >
$index $is_array[
$j] =
$is_array[
$j-1]
$j -= 1
wend
$is_array[
$j] =
$index next
return
$is_arrayendfunc
func ShellSort(ByRef
$some_array)
$increment = 1
while
$increment > 0
for
$i = 2 to uBound(
$some_array)-1
$j =
$i $temp =
$some_array[
$i]
while
$j >=
$increment and
$some_array[
$j-
$increment] >
$temp $some_array[
$j] =
$some_array[
$j-
$increment]
$j =
$j -
$increment wend
$some_array[
$j] =
$temp next
if
$increment/2 <> 0 then
$increment = int(
$increment/2)
elseif
$increment = 1 then
$increment = 0
else
$increment = 1
endif
wend
return
$some_arrayendfunc
func MaxMax(
$num1,
$num2,
$num3=1.7E-308)
if not IsNumber(
$num1) or not IsNumber(
$num2) or not IsNumber(
$num3) then return
if
$num1 >
$num2 then
if
$num3 >
$num1 then return
$num3 return
$num1 else
if
$num3 >
$num2 then return
$num3 return
$num2 endif
endfunc
func MinMin(
$num1,
$num2,
$num3=1.7E+308)
if not IsNumber(
$num1) or not IsNumber(
$num2) or not IsNumber(
$num3) then return
if
$num1 >
$num2 then
if
$num3 <
$num2 then return
$num3 return
$num2 else
if
$num3 <
$num1 then return
$num3 return
$num1 endif
endfunc
func BaseName(
$bn_path)
if StringRight(
$bn_path, 1) =
"\" then
$bn_path = StringTrimRight(
$bn_path, 1)
$bn_path_parts = StringSplit(
$bn_path,
"\")
return
$bn_path_parts[
$bn_path_parts[0]]
endfunc
func GetExtension(
$some_name)
$name_parts = StringSplit(
$some_name,
".")
if
$name_parts[
$name_parts[0]] <>
$some_name and _
not StringInStr(
$name_parts[
$name_parts[0]],
"\") then
return
$name_parts[
$name_parts[0]]
else
return
"" endif
endfunc
func RemoveExtension(
$some_name)
$add = 0
if StringInStr(BaseName(
$some_name),
".") then
$add = 1
return StringTrimRight(
$some_name, StringLen(GetExtension(
$some_name)) +
$add)
endfunc
func CleanName(
$some_name)
return RemoveExtension(BaseName(
$some_name))
endfunc
func GetParent(
$gp_dir)
local
$gp_full_path = StringSplit(
$gp_dir,
"\")
return StringTrimRight(
$gp_dir, StringLen(
$gp_full_path[
$gp_full_path[0]]) + 1)
endfunc
func FolderIsEmpty(
$fie_folder)
local
$fie_search_files = FileFindFirstFile(
$fie_folder &
"\*.*")
if
$fie_search_files = -1 then
if @error = 1 then
FileClose(
$fie_search_files)
return 1
else
return 2
endif
endif
FileClose(
$fie_search_files)
return 0
endfunc
func IsDir(
$some_path)
return StringInStr(FileGetAttrib(
$some_path),
"D")
endfunc
func ReadDir(
$folder,
$extension)
dim
$files[1]
dim
$new_array[2]
$search_files = FileFindFirstFile(
$folder &
"\*." &
$extension)
if
$search_files = -1 then
$search_files = FileFindFirstFile(
$folder &
"\*." &
$extension)
endif
$i = 1
do
$tmp = FileFindNextFile(
$search_files)
$files[
$i-1] =
$tmp $i += 1
redim
$files[
$i]
until @error
FileClose(
$search_files)
$i = 2
for
$this_file in
$files if StringInStr(
$this_file,
$extension, 2) then
redim
$new_array[
$i]
$new_array[0] =
$i-1
$new_array[
$i-1] =
$this_file $i =
$i + 1
endif
next
$files = 0
return
$new_arrayendfunc
func RecurseDir(
$dir,
$mask,
$dont_recurse=false,
$dump=
"",
$return_dirs=false)
dim
$n_dirnames[333333]
local
$n_dircount = 0
local
$n_file local
$n_search local
$n_tfile local
$file_array local
$filenames local
$filecount local
$dircount = 1
local
$msg =
"error" if StringRight(
$dir, 1) =
"\" then
$dir = StringTrimRight(
$dir, 1)
$n_dirnames[
$dircount] =
$dir if not FileExists(
$dir) then return 0
while
$dircount >
$n_dircount $n_dircount += 1
$n_search = FileFindFirstFile(
$n_dirnames[
$n_dircount] &
"\*.*")
while 1
$n_file = FileFindNextFile(
$n_search)
if @error then exitloop
if
$n_file =
"." or
$n_file =
".." then continueloop
$n_tfile =
$n_dirnames[
$n_dircount] &
"\" &
$n_file if StringInStr(FileGetAttrib(
$n_tfile ),
"D") and not
$dont_recurse then
$dircount += 1
$n_dirnames[
$dircount] =
$n_tfile endif
wend
FileClose(
$n_search)
if StringInStr(
$mask,
",", 2) then
$mask_array = StringSplit(
$mask,
",")
else
dim
$mask_array[2] = [1,
$mask]
endif
for
$mask_c = 1 to
$mask_array[0]
$n_search = FileFindFirstFile(
$n_dirnames[
$n_dircount] &
"\" &
$mask_array[
$mask_c] )
if
$n_search = -1 then continueloop
while 1
$n_file = FileFindNextFile(
$n_search)
if @error then exitloop
if
$n_file =
"." or
$n_file =
".." then continueloop
$n_tfile =
$n_dirnames[
$n_dircount] &
"\" &
$n_file if not StringInStr(FileGetAttrib(
$n_tfile ),
"D") then
$filecount += 1
$filenames &=
$n_tfile & @LF
endif
wend
FileClose(
$n_search)
next
wend
if
$return_dirs then
$tmp_str =
"" $i = 1
while
$n_dirnames[
$i] <>
"" $tmp_str &=
$n_dirnames[
$i] &
"|" $i += 1
wend
$tmp_str = StringTrimRight(
$tmp_str, 1)
$n_dirnames = StringSplit(
$tmp_str,
"|")
return
$n_dirnames endif
$filenames = StringTrimRight(
$filenames, 1)
if
$filenames =
"" then return 0
$file_array = StringSplit(
$filenames, @LF)
if
$dump then
$dump_file = FileOpen(
$dump, 2)
FileWrite(
$dump_file,
$filenames)
FileClose(
$dump_file)
endif
return(
$file_array)
endfunc
; returned beginning with a hash
", instead. This improves portability.func GrabCommentsFromIniSection(
$ini_file,
$ini_section,
$make_array=false,
$ignore=
"(*&^(*&%*&^$&^£$^$%*&^%(*&%(")
$whole_file = FileOpen(
$ini_file, 0)
$file_lines = StringSplit(StringStripCR(FileRead(
$whole_file, FileGetSize(
$ini_file))), @LF)
FileClose(
$whole_file)
$comment_string =
"" $found_my_section = false
for
$a = 1 to
$file_lines[0]
$file_lines[
$a] = StringStripWS(
$file_lines[
$a], 3)
if
$found_my_section and StringLeft(
$file_lines[
$a], 1) =
"[" then exitloop
if
$file_lines[
$a] =
"[" &
$ini_section &
"]" then
$found_my_section = true
if
$found_my_section then
if StringLeft(
$file_lines[
$a], 1) =
" then $file_lines[
$a] = StringReplace(
$file_lines[
$a],
";",
", 1) endif
if StringLeft(
$file_lines[
$a], 1) =
" then if not StringInStr(
$file_lines[
$a],
$ignore) then
$comment_string &= @CRLF &
$file_lines[
$a]
endif
endif
endif
next
$comment_string = StringStripWS(
$comment_string, 1)
if
$make_array then return StringSplit(
$comment_string, @CRLF, 1)
return
$comment_stringendfunc
; Nothing else is added. Don't forget to put a
" at the start of each line.func WriteCommentsToIniSection(
$ini_file,
$ini_section,
$comment_string)
FileCopy(
$ini_file, @TempDir &
"\" & Basename(
$ini_file) &
".bax.ini", 1)
IniWrite(
$ini_file,
$ini_section,
"wctis_foo",
"bar")
$whole_file = FileRead(
$ini_file)
$whole_file = StringReplace(
$whole_file,
"[" &
$ini_section &
"]",
"[" &
$ini_section &
"]" & @CRLF &
$comment_string)
$tmp_file = FileOpen(
$ini_file, 2)
FileWrite(
$tmp_file,
$whole_file)
FileClose(
$tmp_file)
if FileGetSize(
$ini_file) < FileGetSize(@TempDir &
"\" & Basename(
$ini_file) &
".bax.ini") then
FileDelete(
$ini_file)
FileCopy(@TempDir &
"\" & Basename(
$ini_file) &
".bax.ini",
$ini_file)
return 0
endif
IniDelete(
$ini_file,
$ini_section,
"wctis_foo")
return 1
endfunc
func IniReadCheckBoxValue(
$rcbv_inifile,
$rcbv_section,
$rcbv_key,
$rcbv_default)
$ircbv_val = IniRead(
$rcbv_inifile,
$rcbv_section,
$rcbv_key,
$rcbv_default)
switch
$ircbv_val case
$GUI_UNCHECKED return
$GUI_UNCHECKED case
"false",
"off",
"no",
"not",
"nope",
"nay",
"nay!",
"nah",
"nah!",
"no way!",
"no sir!",
"negative" return
$GUI_UNCHECKED case
"true",
"on",
"yes",
"yay",
"yay!",
"yup",
"hell yes!",
"indeed",
"yes sir!",
"yessir!",
"affirmative",
"cool" return
$GUI_CHECKED case
"0" return
$GUI_UNCHECKED case
$GUI_CHECKED return
$GUI_CHECKED case else
return
$ircbv_val endswitch
endfunc
func IniWriteCheckBoxValue(
$wcbv_inifile,
$wcbv_section,
$wcbv_key,
$wcbv_val,
$tring=0)
if
$wcbv_val =
$GUI_UNCHECKED then
$wcbv_val =
$tring IniWrite(
$wcbv_inifile,
$wcbv_section,
$wcbv_key,
$wcbv_val)
endfunc
func IniKeyExists(ByRef
$search_array,
$search_string)
if not IsArray(
$search_array) then
return false
endif
for
$i = 1 to
$search_array[0][0]
if
$search_string =
$search_array[
$i][0] then
return
$search_array[
$i][1]
endif
next
return false
endfunc
func InArray(ByRef
$ia_search_array,
$ia_search_string)
if not IsArray(
$ia_search_array) then return false
$ia_limit = UBound(
$ia_search_array) - 1
for
$i = 0 to
$ia_limit if
$ia_search_string =
$ia_search_array[
$i] then
return true
endif
next
return false
endfunc
func MakeDummyArray(
$regular_string)
local
$dummy_array[2] = [1,
$regular_string]
return
$dummy_arrayendfunc
func SaveSizePos(
$ssp_gui,
$ssp_path,
$ssp_section,
$min_width=
"",
$min_height=
"",
$ssp_x=
"",
$ssp_y=
"",
$ssp_w=
"",
$ssp_h=
"")
$wsize_array = WinGetPos(
$ssp_gui)
if not IsArray(
$wsize_array) then return
$x =
$wsize_array[0]
$y =
$wsize_array[1]
$width =
$wsize_array[2]
$height =
$wsize_array[3]
if not
$ssp_x then
$ssp_x =
"x" if not
$ssp_y then
$ssp_y =
"y" if not
$ssp_w then
$ssp_w =
"width" if not
$ssp_h then
$ssp_h =
"height" if
$x < 0 then
$x = 0
if
$y > @DesktopWidth -
$width then
$y = @DesktopWidth -
$width if
$ssp_x <>
"-" then IniWrite(
$ssp_path,
$ssp_section,
$ssp_x,
$x)
if
$ssp_y <>
"-" then IniWrite(
$ssp_path,
$ssp_section,
$ssp_y,
$y)
$width =
$wsize_array[2]
$height =
$wsize_array[3]
if
$min_width =
"" then
$min_width = 100
if
$min_height =
"" then
$min_height = 50
if
$width <
$min_width then
$width =
$min_width if
$height <
$min_height then
$height =
$min_height $size_array = WinGetClientSize(
$ssp_gui)
if IsArray(
$size_array) then
if
$ssp_w <>
"-" then IniWrite(
$ssp_path,
$ssp_section,
$ssp_w,
$size_array[0])
if
$ssp_h <>
"-" then IniWrite(
$ssp_path,
$ssp_section,
$ssp_h,
$size_array[1])
endif
endfunc
func RememberComboSelection(ByRef
$combo_array,
$value)
for
$i = 1 to
$combo_array[0]
if
$combo_array[
$i] =
"" then
if
$combo_array[
$i-1] <>
$value then
$combo_array[
$i] =
$value endif
exitloop
endif
next
endfunc
func GetLastComboSelection(ByRef
$combo_array, ByRef
$names_list)
$new_val =
"" $i =
$combo_array[0]
while
$i > 0
if
$combo_array[
$i] <>
"" then
if not InArray(
$names_list,
$combo_array[
$i]) then
$combo_array[
$i] =
"" $i -= 1
continueloop
endif
$new_val =
$combo_array[
$i]
$combo_array[
$i] =
"" exitloop
endif
$i -= 1
wend
if
$new_val =
"" then
$new_val =
$names_list[
$names_list[0]]
return
$new_valendfunc
func VisitURL(
$vu_url=
"http://corz.org/")
$vu_browser_str = RegRead(
"HKEY_CLASSES_ROOT\HTTP\shell\open\command",
"")
$vu_browser_str = StringReplace(
$vu_browser_str, '
"%1"',
$vu_url)
run(
$vu_browser_str,
"", @SW_SHOW)
endfunc
func UrlToText(
$url)
$start =
"" $end =
"" if StringInStr(
$url,
"*", 0, -1) then
$url_parts = StringSplit(
$url,
"*")
$url =
$url_parts[1]
if uBound(
$url_parts) > 2 then
$start =
$url_parts[2]
if uBound(
$url_parts) > 3 then
$end =
$url_parts[3]
endif
if StringLeft(
$url, 4) =
"http" then
InetGet(
$url, @tempdir &
"\UrlToText.tmp", 1)
local
$handle = FileOpen(@tempdir &
"\UrlToText.tmp", 0)
else
local
$handle = FileOpen(
$url, 0)
endif
$web_text = FileRead(
$handle)
$web_text = StringRegExpReplace(
$web_text, '</(div|p|tr|table)>', '. ')
$web_text = StringRegExpReplace(
$web_text, '\s', ' ')
$web_text = StringRegExpReplace(
$web_text, '<(?i)head(.*?)</(?i)head>', '')
$web_text = StringRegExpReplace(
$web_text, '<(?i)script(.*?)</(?i)script>', '')
$web_text = StringRegExpReplace(
$web_text, '<(?i)style(.*?)</(?i)style>', '')
$web_text = StringRegExpReplace(
$web_text, '</?[^>]*?>', '')
$web_text = ReplaceHTMLEntities(
$web_text)
if
$start then
$web_text = StringTrimLeft(
$web_text, StringInStr(
$web_text,
$start)-1)
endif
$strlen = StringLen(
$web_text)
$end_pos = StringInStr(
$web_text,
$end)
if
$end_pos = 0 then
$end_pos =
$strlen if
$end then
$web_text = StringTrimRight(
$web_text,
$strlen-
$end_pos+1)
endif
FileClose(
$handle)
FileDelete(@tempdir &
"\UrlToText.tmp")
return StringStripWS(
$web_text, 4)
endfunc
func ReplaceHTMLEntities(
$text)
for
$i = 32 to 255
$text = StringReplace(
$text, String('&
next
$text = StringReplace(
$text,
"Á, "Á") $text = StringReplace(
$text,
"á, "á") $text = StringReplace(
$text,
"Â, "Â") $text = StringReplace(
$text,
"â, "â") $text = StringReplace(
$text,
"´, "´") $text = StringReplace(
$text,
"Æ, "Æ") $text = StringReplace(
$text,
"æ, "æ") $text = StringReplace(
$text,
"À, "À") $text = StringReplace(
$text,
"à, "à") $text = StringReplace(
$text,
"&alefsym, "?") $text = StringReplace(
$text,
"&Alpha, "?") $text = StringReplace(
$text,
"&alpha, "?") $text = StringReplace(
$text,
"&, "&") $text = StringReplace(
$text,
"&and, "?") $text = StringReplace(
$text,
"&ang, "?") $text = StringReplace(
$text,
"Å, "Å") $text = StringReplace(
$text,
"å, "å") $text = StringReplace(
$text,
"&asymp, "?") $text = StringReplace(
$text,
"Ã, "Ã") $text = StringReplace(
$text,
"ã, "ã") $text = StringReplace(
$text,
"Ä, "Ä") $text = StringReplace(
$text,
"ä, "ä") $text = StringReplace(
$text,
"&bdquo, "?") $text = StringReplace(
$text,
"&Beta, "?") $text = StringReplace(
$text,
"&beta, "?") $text = StringReplace(
$text,
"¦, "¦") $text = StringReplace(
$text,
"&bull, "?") $text = StringReplace(
$text,
"&cap, "?") $text = StringReplace(
$text,
"Ç, "Ç") $text = StringReplace(
$text,
"ç, "ç") $text = StringReplace(
$text,
"¸, "¸") $text = StringReplace(
$text,
"¢, "¢") $text = StringReplace(
$text,
"&Chi, "?") $text = StringReplace(
$text,
"&chi, "?") $text = StringReplace(
$text,
"&circ, "?") $text = StringReplace(
$text,
"&clubs, "?") $text = StringReplace(
$text,
"&cong, "?") $text = StringReplace(
$text,
"©, "©") $text = StringReplace(
$text,
"&crarr, "?") $text = StringReplace(
$text,
"&cup, "?") $text = StringReplace(
$text,
"¤, "¤") $text = StringReplace(
$text,
"&dagger, "?") $text = StringReplace(
$text,
"&Dagger, "?") $text = StringReplace(
$text,
"&darr, "?") $text = StringReplace(
$text,
"&dArr, "?") $text = StringReplace(
$text,
"°, "°") $text = StringReplace(
$text,
"&Delta, "?") $text = StringReplace(
$text,
"&delta, "?") $text = StringReplace(
$text,
"&diams, "?") $text = StringReplace(
$text,
"÷, "÷") $text = StringReplace(
$text,
"É, "É") $text = StringReplace(
$text,
"é, "é") $text = StringReplace(
$text,
"Ê, "Ê") $text = StringReplace(
$text,
"ê, "ê") $text = StringReplace(
$text,
"È, "È") $text = StringReplace(
$text,
"è, "è") $text = StringReplace(
$text,
"&empty, "?") $text = StringReplace(
$text,
"&emsp, "?") $text = StringReplace(
$text,
"&ensp, "?") $text = StringReplace(
$text,
"&Epsilon, "?") $text = StringReplace(
$text,
"&epsilon, "?") $text = StringReplace(
$text,
"&equiv, "?") $text = StringReplace(
$text,
"&Eta, "?") $text = StringReplace(
$text,
"&eta, "?") $text = StringReplace(
$text,
"Ð, "Ð") $text = StringReplace(
$text,
"ð, "ð") $text = StringReplace(
$text,
"Ë, "Ë") $text = StringReplace(
$text,
"ë, "ë") $text = StringReplace(
$text,
"&euro, "?") $text = StringReplace(
$text,
"&exist, "?") $text = StringReplace(
$text,
"&fnof, "?") $text = StringReplace(
$text,
"&forall, "?") $text = StringReplace(
$text,
"½, "½") $text = StringReplace(
$text,
"¼, "¼") $text = StringReplace(
$text,
"¾, "¾") $text = StringReplace(
$text,
"&frasl, "?") $text = StringReplace(
$text,
"&Gamma, "?") $text = StringReplace(
$text,
"&gamma, "?") $text = StringReplace(
$text,
"&ge, "?") $text = StringReplace(
$text,
">, ">") $text = StringReplace(
$text,
"&harr, "?") $text = StringReplace(
$text,
"&hArr, "?") $text = StringReplace(
$text,
"&hearts, "?") $text = StringReplace(
$text,
"&hellip, "?") $text = StringReplace(
$text,
"Í, "Í") $text = StringReplace(
$text,
"í, "í") $text = StringReplace(
$text,
"Î, "Î") $text = StringReplace(
$text,
"î, "î") $text = StringReplace(
$text,
"¡, "¡") $text = StringReplace(
$text,
"Ì, "Ì") $text = StringReplace(
$text,
"ì, "ì") $text = StringReplace(
$text,
"&image, "?") $text = StringReplace(
$text,
"&infin, "?") $text = StringReplace(
$text,
"&int, "?") $text = StringReplace(
$text,
"&Iota, "?") $text = StringReplace(
$text,
"&iota, "?") $text = StringReplace(
$text,
"¿, "¿") $text = StringReplace(
$text,
"&isin, "?") $text = StringReplace(
$text,
"Ï, "Ï") $text = StringReplace(
$text,
"ï, "ï") $text = StringReplace(
$text,
"&Kappa, "?") $text = StringReplace(
$text,
"&kappa, "?") $text = StringReplace(
$text,
"&Lambda, "?") $text = StringReplace(
$text,
"&lambda, "?") $text = StringReplace(
$text,
"&lang, "?") $text = StringReplace(
$text,
"«, "«") $text = StringReplace(
$text,
"&larr, "?") $text = StringReplace(
$text,
"&lArr, "?") $text = StringReplace(
$text,
"&lceil, "?") $text = StringReplace(
$text,
"&ldquo, "?") $text = StringReplace(
$text,
"&le, "?") $text = StringReplace(
$text,
"&lfloor, "?") $text = StringReplace(
$text,
"&lowast, "?") $text = StringReplace(
$text,
"&loz, "?") $text = StringReplace(
$text,
"&lrm, "?") $text = StringReplace(
$text,
"&lsaquo, "?") $text = StringReplace(
$text,
"&lsquo, "?") $text = StringReplace(
$text,
"<, "<") $text = StringReplace(
$text,
"¯, "¯") $text = StringReplace(
$text,
"&mdash, "?") $text = StringReplace(
$text,
"µ, "µ") $text = StringReplace(
$text,
"·, "·") $text = StringReplace(
$text,
"&minus, "?") $text = StringReplace(
$text,
"&Mu, "?") $text = StringReplace(
$text,
"&mu, "?") $text = StringReplace(
$text,
"&nabla, "?") $text = StringReplace(
$text,
" , " ") $text = StringReplace(
$text,
"&ndash, "?") $text = StringReplace(
$text,
"&ne, "?") $text = StringReplace(
$text,
"&ni, "?") $text = StringReplace(
$text,
"¬, "¬") $text = StringReplace(
$text,
"¬in, "?") $text = StringReplace(
$text,
"&nsub, "?") $text = StringReplace(
$text,
"Ñ, "Ñ") $text = StringReplace(
$text,
"ñ, "ñ") $text = StringReplace(
$text,
"&Nu, "?") $text = StringReplace(
$text,
"&nu, "?") $text = StringReplace(
$text,
"Ó, "Ó") $text = StringReplace(
$text,
"ó, "ó") $text = StringReplace(
$text,
"Ô, "Ô") $text = StringReplace(
$text,
"ô, "ô") $text = StringReplace(
$text,
"&OElig, "?") $text = StringReplace(
$text,
"&oelig, "?") $text = StringReplace(
$text,
"Ò, "Ò") $text = StringReplace(
$text,
"ò, "ò") $text = StringReplace(
$text,
"&oline, "?") $text = StringReplace(
$text,
"&Omega, "?") $text = StringReplace(
$text,
"&omega, "?") $text = StringReplace(
$text,
"&Omicron, "?") $text = StringReplace(
$text,
"&omicron, "?") $text = StringReplace(
$text,
"&oplus, "?") $text = StringReplace(
$text,
"&or, "?") $text = StringReplace(
$text,
"ª, "ª") $text = StringReplace(
$text,
"º, "º") $text = StringReplace(
$text,
"Ø, "Ø") $text = StringReplace(
$text,
"ø, "ø") $text = StringReplace(
$text,
"Õ, "Õ") $text = StringReplace(
$text,
"õ, "õ") $text = StringReplace(
$text,
"&otimes, "?") $text = StringReplace(
$text,
"Ö, "Ö") $text = StringReplace(
$text,
"ö, "ö") $text = StringReplace(
$text,
"¶, "¶") $text = StringReplace(
$text,
"&part, "?") $text = StringReplace(
$text,
"&permil, "?") $text = StringReplace(
$text,
"&perp, "?") $text = StringReplace(
$text,
"&Phi, "?") $text = StringReplace(
$text,
"&phi, "?") $text = StringReplace(
$text,
"&Pi, "?") $text = StringReplace(
$text,
"&pi, "?") $text = StringReplace(
$text,
"&piv, "?") $text = StringReplace(
$text,
"±, "±") $text = StringReplace(
$text,
"£, "£") $text = StringReplace(
$text,
"&prime, "?") $text = StringReplace(
$text,
"&Prime, "?") $text = StringReplace(
$text,
"&prod, "?") $text = StringReplace(
$text,
"&prop, "?") $text = StringReplace(
$text,
"&Psi, "?") $text = StringReplace(
$text,
"&psi, "?") $text = StringReplace(
$text,
"", '"')
$text = StringReplace($text, "&radic&rang»&rarr&rArr&rceil&rdquo&real®&rfloor&Rho&rho&rlm&rsaquo&rsquo&sbquo&Scaron&scaron&sdot§­&Sigma&sigma&sigmaf&sim&spades&sub&sube&sum¹²³&sup&supeß&Tau&tau&there4&Theta&theta&thetasym&thinspÞþ&tilde×&tradeÚú&uarr&uArrÛûÙù¨&upsih&Upsilon&upsilonÜü&weierp&Xi&xiÝý¥ÿ&Yuml&Zeta&zeta&zwj&zwnj\error.log
", "")
FileWriteLine(@ScriptDir & "\error.log
", _
"--------------------------------------------------------------------------------
")
FileWriteLine(@ScriptDir & "\error.log
", @Year & "/
" & @Mon & "/
" & @MDay _
& " " & @Hour & ":
" & @Min & ":
" & @Sec )
FileWriteLine(@ScriptDir & "\error.log
", "")
FileWriteLine(@ScriptDir & "\error.log
", "command-line:
" & $CmdLineRaw)
FileWriteLine(@ScriptDir & "\error.log
", "")
FileWriteLine(@ScriptDir & "\error.log
", $error_string)
endfunc
global $log_string
global $my_shortname
if $my_shortname = "" then $my_shortname = "application
"
global $log_file
if $log_file = "" then $log_file = @ScriptFullPath&".log
"
out" as your log string
out" command, eg..
out", 0, "command-line: " & $my_arguments & @CRLF & @CRLF)
func DoLog($dl_string, $dl_append=4, $log_extra="")
if $dl_string = "out
" then
if $log_string <> "" then
if $dl_append = 1 then
$dl_append = 9
else
$dl_append = 10
endif
$my_log_file = FileOpen($log_file, $dl_append)
FileWriteLine($my_log_file, "corz
" & $my_shortname & " log @
"&@YEAR&"-
"&@MON&"-
"&@MDAY&"..
" & @CRLF & _
"--------------------------------------------------------------------------------
" & @CRLF & @CRLF)
if $log_extra = "" then FileWriteLine($my_log_file, "command-line:
" & $CmdLineRaw)
FileWriteLine($my_log_file, $log_extra)
FileWriteLine($my_log_file, $log_string & @CRLF & @CRLF)
FileClose($my_log_file)
$log_string = ""
endif
else
$log_string &= $dl_string & @CRLF
endif
endfunc
func PrintArray(ByRef $array, $tring="array
", $limit=0)
if not IsArray($array) then
ConsoleWrite($tring & ": NOT an array!
" & @LF)
ConsoleWrite("it's a string:
" & "->
" & $tring & "<-
" & @LF & @LF)
return 0
endif
local $pa_string = ""
local $count = 0
for $element in $array
$pa_string &= '[' & $count & '] : ' & $element & @LF
$count += 1
if $count = $limit then exitloop
next
SplashOff()
ProgressOff()
ConsoleWrite($tring & ":
" & @LF & $pa_string & @LF & @LF)
endfunc
func DumpArray(ByRef $array, $dump_file)
if not IsArray($array) then return 0
local $da_string = ""
local $count = 0
for $element in $array
$da_string &= '[' & $count & '] : ' & $element & @CRLF
$count += 1
next
FileWrite($dump_file, $da_string)
endfunc
func debug($d_string)
if @compiled then return
ConsoleWrite($d_string & @LF)
endfunc
func ExitReport($er_string)
MsgBox(262160, "Error:
", "An error occured!
" & @CRLF & $er_string, 60)
exit
endfunc
Func ArrayBox(ByRef $Array, $ArrayBase = 1, $sTitle = 'Array Box', $Width = 350, $Height = 350, $Left = -1, $Top = -1)
Dim $AllDone = 0, $msg, $i, $j, $ArrayDimensions = UBound($Array, 0)
Dim $hndForm_Main, $hndListView_Display
If $ArrayDimensions = 0 Then
SetError(1)
Return -1
EndIf
If $ArrayBase <> 0 Then $ArrayBase = 1
If $ArrayBase Then
Select
Case $ArrayDimensions = 1
$ArrayMax = $Array[0]
Case $ArrayDimensions = 2
$ArrayMax = $Array[0][0]
EndSelect
Else
$ArrayMax = UBound($Array, 1) - 1
EndIf
If $Height < 100 Then $Height = 100
If $Width < 100 Then $Width = 100
$last_event_mode = AutoItSetOption("GUIOnEventMode
", 1)
$hndForm_Main = GUICreate($sTitle, $Width, $Height, $Left, $Top, BitOR(0x80000000, 0x00C00000, 0x00040000))
GUISetOnEvent(-3, "QuitBox
" , $hndForm_Main)
If $ArrayDimensions = 1 Then
$sTemp = 'Index|Value'
ElseIf $ArrayDimensions = 2 Then
$sTemp = 'Index'
For $i = 0 To UBound($Array, 2) - 1
$sTemp = $sTemp & '|' & $i
Next
EndIf
$hndListView_Display = GUICtrlCreateListView($sTemp, 0, 0, $Width, $Height-32, BitOR(0x0008, 0x0004))
GUICtrlSetResizing($hndListView_Display, BitOR(0x0002, 0x0020, 0x0004, 0x0040))
$hndButton_Close = GUICtrlCreateButton('&Close',$Width-83,$Height-30,80,24)
GUICtrlSetOnEvent(-1, "QuitBox
")
GUICtrlSetResizing(-1, BitOR(0x0004, 0x0040, 0x0300))
GUICtrlSetState($hndButton_Close, 512)
GUISetState (@SW_SHOW, $hndForm_Main)
Select
Case $ArrayDimensions = 1
For $i = $ArrayBase To $ArrayMax
GUICtrlCreateListViewItem($i & '|' & $Array[$i], $hndListView_Display)
Next
Case $ArrayDimensions = 2
For $i = $ArrayBase To $ArrayMax
$sTemp=$Array[$i][0]
for $j = 1 To UBound($Array, 2) - 1
$sTemp = $sTemp & '|' & $Array[$i][$j]
Next
GUICtrlCreateListViewItem('[' & $i & ']|' & $sTemp, $hndListView_Display)
Next
Case Else
EndSelect
global $QuitBox = 0
do
Sleep(100)
until $QuitBox = 1
AutoItSetOption("GUIOnEventMode
", $last_event_mode)
GUIDelete($hndForm_Main)
Return 0
EndFunc
Func ce_Singleton($occurenceName, $flag = 0)
Local $ERROR_ALREADY_EXISTS = 183
$occurenceName = StringReplace($occurenceName, "\
", "")
Local $handle = DllCall("kernel32.dll
", "int
", "CreateMutex
", "int
", 0, "long
", 1, "str
", $occurenceName)
Local $lastError = DllCall("kernel32.dll
", "int
", "GetLastError
")
If $lastError[0] = $ERROR_ALREADY_EXISTS Then
If $flag = 0 Then
Exit -1
Else
SetError($lastError[0])
Return 0
EndIf
EndIf
Return $handle[0]
EndFunc
func ce_IsPressed($Key)
local $kp = DllCall('user32.dll', "int
", "GetAsyncKeyState
", "int
", '0x' & $Key)
if not @error and BitAND($kp[0], 0x8000) = 0x8000 then return 1
return 0
endfunc
func QuitBox()
$QuitBox = 1
endfunc
\a", as expected, but removed it from
"dev\all files", making "devll files", unexpected!
Now we simply trim off "so-many" characters from the right. the
"so-many" being the length of the final part of the path.
* BaseName() will now trim any traling slashes you might have left at the
end of the folder path, before working on the string.
"