配列操作
safe = split("1 2 3 4 5 6 7 8 9 0")
Filter(safe, "(% mod 2) = 1")
Map(safe, "% + <#DBL> は奇数<#DBL>")
for v in safe
print v
next
print
hashtbl hash
hash["a"] = 1
hash["b"] = 2
hash["c"] = null
hash["d"] = 4
hash["e"] = "abcde"
Where(hash, "chknum(%)")
Select(hash, "% * 2")
for key in hash
print hash[key]
next
id = getid(GET_LOGPRINT_WIN)
while status(id, ST_VISIBLE)
sleep(0.1)
wend
procedure Filter(var arr[], expression)
try
dummy = arr[0, HASH_EXISTS]
isHashtbl = TRUE
except
isHashtbl = FALSE
endtry
if isHashtbl then
for key in arr
% = arr[key]
& = key
try
res = eval(expression)
select res
case TRUE, FALSE
default
res = TRUE
selend
except
msgbox("不正な式: " + expression + "<#CR>% = " + %)
exit
endtry
if ! res then
dummy = arr[key, HASH_REMOVE]
endif
next
else
dim _arr[resize(arr)]
n = 0
for % in arr
try
res = eval(expression)
select res
case TRUE, FALSE
default
res = TRUE
selend
except
msgbox("不正な式: " + expression + "<#CR>% = " + %)
exit
endtry
if res then
_arr[n] = %
n = n + 1
endif
next
for i = 0 to resize(arr, n - 1)
arr[i] = _arr[i]
next
endif
fend
procedure Map(var arr[], expression)
try
dummy = arr[0, HASH_EXISTS]
isHashtbl = TRUE
except
isHashtbl = FALSE
endtry
if isHashtbl then
dummy = arr[0, HASH_EXISTS]
for key in arr
% = arr[key]
& = key
try
arr[key] = eval(expression)
except
msgbox("不正な式: " + expression + "<#CR>% = " + %)
exit
endtry
next
else
for i = 0 to resize(arr)
% = arr[i]
try
arr[i] = eval(expression)
except
msgbox("不正な式: " + expression + "<#CR>% = " + %)
exit
endtry
next
endif
fend
procedure Where(var arr[], expression)
Filter(arr, expression)
fend
procedure Select(var arr[], expression)
Map(arr, expression)
fend