home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 December
/
VPR9712A.ISO
/
OLS
/
WIN32
/
COMWP380
/
comwp380.exe
/
SAMPLES.EXE
/
SAMPLE4B.CWS
< prev
next >
Wrap
Text File
|
1997-08-25
|
11KB
|
562 lines
#-----------------------------------#
# Sample4b.cws for ComWin Ver. 3.80 #
#-----------------------------------#
#-------------------------------------------------------------#
#----------#
# メニュー #
#----------#
let @ number = -1
until ($number != 0)
echo ^^e[43m 1...ウィンドウ操作 ^^e[m
echo ^^e[46m 2...数値操作 ^^e[m
echo ^^e[42m 3...時間操作 ^^e[m
echo ^^e[45m 4...ファイル操作 ^^e[m
echo ^^e[41m 5...表示操作 ^^e[m
echo ^^e[43m 6...アドレス操作 ^^e[m
echo ^^e[46m 7...引数操作 ^^e[m
echo ^^e[42m 8...リスト操作 ^^e[m
echo ^^e[45m 9...文字操作 ^^e[m
echo ^^e[47m 0...終了 ^^e[m
echo メニュー番号?=^^ ;let number
if "%number%" == "" let @ number = -1
switch (%number%)
case 1 :
call @ window
breaksw
case 2 :
call @ calc 100.0 6
breaksw
case 3 :
%0 -@:time # sample4b.cws -@:time arg1 ... のような呼び出しも可
breaksw
case 4 :
call @ file
breaksw
case 5 :
call @ echo
breaksw
case 6 :
call @ address
breaksw
case 7 :
call @ args This is an argument sample script.
breaksw
case 8 :
call @ list
breaksw
case 9 :
call @ character "This is a character sample script."
breaksw
case 0 :
echo 終了しますか?(y/n)^^ ;let yn
if not "%yn%" == "y" let @ number = -1
breaksw
default :
echo もう一度入力してください。^^a
breaksw
endsw
end
return 0
#-------------------------------------------------------------#
proc file
#--------------#
# ファイル操作 #
#--------------#
echo 指定したファイルに行番号を付加します。
while (1)
echo 入力ファイル名?=^^ ;let fi
if "%fi%" == "" continue
if not exist %fi% then
echo 入力ファイルが存在しません。
continue
endif
break
end
while (1)
echo 出力ファイル名?=^^ ;let fo
if "%fo%" == "" continue
if exist %fo% then
echo 既存のファイルに上書きはできません。
continue
endif
break
end
call @ addline < %fi% > %fo%
type %fo%
pause
return
proc addline
for (i = 1; 1; i++)
let buf
if (*status > 0) break
set @ argv[2] = *i
set @ argv[3] = *buf
printf "^%^6d:^%s\n" argv[2] argv[3]
end
set argv[2]=
set argv[3]=
return
#-------------------------------------------------------------#
proc window
#----------------#
# ウィンドウ操作 #
#----------------#
let appname=電卓
let appprog=calc
#let appname=メモ帳 - (無題)
#let appprog=notepad
echo %appname%を起動します。 ;pause ;%appprog%
gosub leftup
gosub leftdown
gosub rightdown
gosub rightup
echo %appname%を終了します。 ;pause ;kill "[%appname%]"
return
:leftup
let @ x = 0
let @ y = 200
while ($x <= 200)
SetWindowPos "[%appname%]" 0 %x% %y% 0 0 0001
let @ x += 4 ;
let @ y -= 4
end
return
:leftdown
let @ x = 200
let @ y = 0
while ($x <= 400)
SetWindowPos "[%appname%]" 0 %x% %y% 0 0 0001
let @ x += 4
let @ y += 4
end
return
:rightdown
let @ x = 400
let @ y = 200
while ($x >= 200)
SetWindowPos "[%appname%]" 0 %x% %y% 0 0 0001
let @ x -= 4
let @ y += 4
end
return
:rightup
let @ x = 200
let @ y = 400
while ($x >= 0)
SetWindowPos "[%appname%]" 0 %x% %y% 0 0 0001
let @ x -= 4
let @ y -= 4
end
return
#--------------------------------------------------------------#
proc calc
#----------#
# 数値操作 #
#----------#
if "%1" == "" then
let @ a = 10.0
else
let a=%1
endif
if "%2" == "" then
let @ b = 4
else
let b=%2
endif
let @ c = $a * $b
echo %a% * %b% = %c%
let @ c = $a / $b
echo %a% / %b% = %c%
let @ c = $a % $b
echo %a% % %b% = %c%
let @ c = $a + $b
echo %a% + %b% = %c%
let @ c = $a - $b
echo %a% - %b% = %c%
let @ c = $a ^<^< $b
echo %a% ^<^< %b% = %c%
let @ c = $a ^>^> $b
echo %a% ^>^> %b% = %c%
let @ c = $a ^< $b
echo %a% ^< %b% = %c%
let @ c = $a ^> $b
echo %a% ^> %b% = %c%
let @ c = $a ^<= $b
echo %a% ^<= %b% = %c%
let @ c = $a ^>= $b
echo %a% ^>= %b% = %c%
let @ c = $a == $b
echo %a% == %b% = %c%
let @ c = $a != $b
echo %a% != %b% = %c%
let @ c = $a & $b
echo %a% & %b% = %c%
let @ c = $a ^^ $b
echo %a% ^^^^ %b% = %c%
let @ c = $a ^| $b
echo %a% ^| %b% = %c%
let @ c = $a && $b
echo %a% && %b% = %c%
let @ c = $a ^|^| $b
echo %a% ^|^| %b% = %c%
pause
return
#--------------------------------------------------------------#
proc time
#----------#
# 時間操作 #
#----------#
echo | time | let time
echo | date | let date
echo %date%
echo %time%
pause
return
#--------------------------------------------------------------#
proc echo
#----------#
# 表示操作 #
#----------#
mode con cols=128 lines=500
foreach file (*.*)
echo %file% ^^c
end
echo
let @ i = 1;
foreach file (*.*)
echo %i%:%file%
let @ i++
end
pause
return
#--------------------------------------------------------------#
proc address
#--------------#
# アドレス操作 #
#--------------#
echo 配列を設定
call @ address_set_array &array 0 10
echo 配列を表示
call @ address_disp_array &array 0 10
echo 配列を降順にソート
call @ address_sort_array &array 0 10
echo 配列を表示
call @ address_disp_array &array 0 10
pause
return
#----------------#
# 配列に値を設定 #
#----------------#
proc address_set_array
let array=%1
let min=%2
let max=%3
let @ i = $min
while ($i < $max)
let @ %array%[%i%] = $i
let @ i++
end
return
#------------#
# 配列を表示 #
#------------#
proc address_disp_array
let array=%1
let min=%2
let max=%3
let @ i = $min
while ($i < $max)
let @ value = $%array%[%i%]
echo %value% ^^
let @ i++
end
echo
return
#------------#
# 配列を整列 #
#------------#
proc address_sort_array
echo ソート中です...^^
let array=%1
let min=%2
let max=%3
let @ count = 0
let @ i = $min
while ($i < $max - 1)
let @ j = $i + 1
while ($j < $max)
if ($%array%[%i%] < $%array%[%j%]) then
let @ value = $%array%[%i%]
let @ %array%[%i%] = $%array%[%j%]
let @ %array%[%j%] = $value
let @ count++
endif
let @ j++
end
let @ i++
end
echo ^^rソート終了しました。
echo 交換回数は %count% 回です。
return
#--------------------------------------------------------------#
proc args
#----------#
# 引数操作 #
#----------#
gosub setargs
let @ i = 0
while ($i < $argc)
let @ argv = $argv[%i%]
echo 第 %i% 引数 : %argv%
let @ i += 1
end
pause
return
:setargs
let @ argc = 0
while ("%0" != "")
let argv[%argc%]=%0
let @ argc++
shift
end
echo ---全ローカル環境変数---
let
echo ------------------------
return
#--------------------------------------------------------------#
proc list
#------------#
# リスト操作 #
#------------#
#--------------------#
# 先頭のセルを初期化 #
#--------------------#
let @ memorycounter = 0
let @ new = cell[%memorycounter%] ; let @ memorycounter++
let @ top = $new
let @ cur = $new
#------------------#
# 9 個のセルを確保 #
#------------------#
let @ i = 1;
while ($i < 10)
let @ new = cell[%memorycounter%] ; let @ memorycounter++
let @ %cur%.next = $new
let @ cur = $new
let @ i++
end
#----------------------#
# セルをたどり値を代入 #
#----------------------#
let @ i = 0
let @ s = 0
let @ cur = $top
while ("%cur%" != "")
let @ i += 1
let @ s += $i
let @ %cur%.value = $s
let @ cur = $%cur%.next
end
#-------------------------------#
# セルをたどり値を表示 (漢字編) #
#-------------------------------#
let 先頭=top
let 次=next
let 本体=value
let @ 今 = $%先頭%
while ("%今%" != "")
let @ 値 = $%今%.%本体%
echo %値% ^^
let @ 今 = $%今%.%次%
end
echo
#----------------------#
# 先頭の次のセルを削除 #
#----------------------#
let @ cur = $%top%.next
let @ %top%.next = $%cur%.next
let %cur%.value=
let %cur%.next=
let cur=
#---------------------------------------#
# セルをたどり値を表示 (サブルーチン編) #
#---------------------------------------#
gosub displaycell
#----------------------------#
# 先頭の次に新しいセルを追加 #
#----------------------------#
let @ new = cell[%memorycounter%] ; let @ memorycounter++
let @ cur = $%top%.next
let @ %top%.next = $new
let @ %new%.next = $cur
let @ %new%.value = 0
#---------------------------------------#
# セルをたどり値を表示 (プロシージャ編) #
#---------------------------------------#
call @ displaycell &%top% &cell
#--------------------------#
# セルをたどり各セルを開放 #
#--------------------------#
let @ cur = $top
while ("%cur%" != "")
let @ tmp = $cur
let @ cur = $%cur%.next
let %tmp%.value=
let %tmp%.next=
let tmp=
end
pause
return
#----------------------------#
# セルを表示するサブルーチン #
#----------------------------#
:displaycell
let @ cur = $top
while ("%cur%" != "")
let @ value = $%cur%.value
echo %value% ^^
let @ cur = $%cur%.next
end
echo
return
#----------------------------#
# セルを表示するプロシージャ #
#----------------------------#
proc displaycell
let cur=%1
while ("%cur%" != "&")
let @ value = $%cur%.value
echo %value% ^^
let @ cur = &$%cur%.next
end
echo
return
#--------------------------------------------------------------#
proc character
#----------#
# 文字操作 #
#----------#
#--------------#
# 文字列の長さ #
#--------------#
let @ str1= `echo This is a character sample script.` # バッククォート
let @ i = 0
while ($str1:$i != 0) # 文字 ---> 数値
let @ i++
end
echo %str1% の長さは %i% 文字です。
#------------#
# 文字コード #
#------------#
for (i = 0x81; $i <= 0x9F; i++)
for (j = 0x40; $j <= 0xFC; j++)
if ($j == ~~0x7F) continue # 10進整数表示で比較
let @ c = :($i * 0x100 + $j) # 数値 ---> 文字
echo %c%^^c
end
end
for (i = 0xE0; $i <= 0xFC; i++)
for (j = 0x40; $j <= 0xFC; j++)
if ($j == ~~0x7F) continue # 10進整数表示で比較
let @ c = :($i * 0x100 + $j) # 数値 ---> 文字
echo %c%^^c
end
end
echo
pause
return
#--------------------------------------------------------------#