TclAPI

ascii

api ascii $char

return ascii_code

アーギュメントの先頭文字のASCIIコードを10進数で返します
api charと逆の機能です

base64_encodeex

api base64_encodeEx $text $text_len $out_varname

return length

文字数$text_lenの文字列$textをBASE64エンコードして変数out_varnameに格納します
エンコード後の文字数を返します

base64_encode

api base64_encode $text $text_len out_varname

return length

文字数$text_lenの文字列$textをBASE64エンコードして変数out_varnameに格納します
エンコード後の文字数を返します

base64_decodeex

api base64_decodeEx $base64 out_varname

return length

文字数$base64をBASE64デコードして変数out_varnameに格納します
デコード後の文字数を返します

base64_decode

api base64_decode $base64_text out_varname

return length

BASE64コードの文字列$base64_textをデコードして変数out_varnameに格納します
デコード後の文字数を返します
失敗するとout_varnameには空文字が格納され0が返ります

close

api close $path

return 0

api openで開かれたファイルを閉じます

参照:
api open
api gets
api seek
api tell

copyfile

api copyFile $fileA $fileB $noexists

return success

ファイルをコピーします($fileA --> $fileB)
$noexistsが1の場合、fileBが存在すれば失敗します
$noexistsが0の場合、fileBが存在していても上書きされます
成功すれば1が返ります

chmod

api chmod $mode $filename

return success

api chmod $filename

return hexval

ファイル属性の書込み禁止/許可を設定します
$mode
-w : 書き込み禁止
+w : 書き込み許可
+x[0-9]+ : 後続のHEX値をセット
-x[0-9]+ : 後続のHEX値をリセット
$modeを省略すると現在のファイル属性が16進数で返ります
0xffffffffが返ればファイルが無いことを意味します

char

api char $ascii_code

return $char

ASCIIコード(10進数)の文字を返します
api asciiと逆の機能です

date

api date

return date_text

現在の日付と時間を返します
フォーマット : "YYYY/MM/DD hh/mm/ss"

daylength

api daylength $from_date $to_date

return days

指定した日付間の期間を日数で返します(閏年等も考慮します)
set days [api daylength 1998/12/01 2008/01/15]

decodebase64

api decodeBase64 $cmpressed_data

return uncompressed_data

api encodeBase64で書き出されたファイルの全データを受け取り、デコードデータを返す
gui decodeBase64 と同じ機能です。

decr

api decr $tcl_object_handle

return 0

Tclオブジェクトの参照カウンタを減じます

encodebase64

api encodeBase64 $infile $outfile $before $after

return err

api encodeBase64 $text

return base64

infileファイルを読みoutfileにBase64エンコードしたデータを書き出す
エンコードデータに付け加えるヘッダとフッダデータをbeforeとafterに指定する
成功したら0を返す
gui encodeBase64 と同じ機能です

eof

api eof $fp

return {1|0}

exec

api exec $cmd [$arg1 ...]

return pid

アーギュメントで与えられたOSへのコマンドラインを実行しプロセスidを返します
プロセスidはウインドウをもつプロセスの場合に有効です
このプロセスidをapi waitに渡して終了を待つことができます

参照:
api wait
api kill

exitthread

api exitThread

return 1

スレッドスクリプトまたはスレッドプロシージャを終了します
スレッドスクリプトまたはスレッドプロシージャの中で実行します

スレッドプロシージャはapi threadで起動できます
スレッドスクリプトはapi threadEvalで起動できます

errorstring

api errorString $errno

return error_text

OSが返したエラー番号を文字列に変換して返します
参照:api getLastError

fetch

api fetch $fp $adr *data

return next_adr

filedelete

api filedelete $file

return handle

プロセス終了後にファイルを削除します
-1が返されたら失敗です

filemtime

api filemtime $filename $time

ファイルの更新日付を修正します
$timeは"YYYY/MM/DD HH:MM:SS"で与えます

freespace

api freeSpace $drive [$use]

return size

ディスクの空き容量をバイトサイズで返します
$useに1をセットして与えると使用容量を返します
set size [api freeSpae D:]

getdrivetype

api getdrivetype $drive

return type

ドライブのタイプを返します

typeは下記のいずれかです
unknown
noroot
removable
fixed
remote
cdrom
ramdisk

getvolumelabel

api getvolumelabel $drive [name]

return "VolumeNameBuffer:VolumeSerialNumber"

getlongpath

api getlongpath $path

return longpath

gets

api gets $path varname

return size

api openで開かれたファイルから1行を変数varnameに読み込みます
LFコードを行末と見なしは含まない文字列を返します
読み込んだサイズを返します。EOFに到達した場合は-1を返します。

参照:
api open
api close
api seek
api tell

getapppath

api getAppPath $exefilename

return path

実行ファイル名をフルパスで返します

api exec [api getAppPath exel.exe]

下記レジストリにセットされている値を返します
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/App Paths/$exefilename

getsystemdirectory

api getSystemDirectory

return path

Windowsのシステムディレクトリィを返します
例:"C:\WINDOWS\System32"
システムドライブ名を得る時に有効です

getwindowsdirectory

api getWindowsDirectory

return path

WindowsのWINDOWSディレクトリィを返します
例:"C:\WINDOWS\System32"
システムドライブ名を得る時に有効です

getcurrentpath

api getCurrentPath

return path

現在の作業フォルダ名を返します
tclコマンド"pwd"と同等です

getcomputername

api getComputerName

return pcname

コンピュータ名を返します

参照:
api getHostName
api myHostName

getipaddress

api getIPaddress $hostname

return ipaddress

ホスト名からIPアドレスを得て返します
api getHostnameと逆の機能です

使用例:
api myHostName
→yoshida3
api getIPaddress yoshida3
→192.168.100.16
api getIPaddress localhost
→127.0.0.1

gethostname

api getHostName $ipaddress

return hostname

IPアドレスからホスト名を得て返します
api getIPadddressと逆の機能です

getenv

api getEnv $varname

return val

Windows環境変数の値を返します

set temppath [api getEnv TEMP]

getvar

api getVar $varname

return val

スレッドを起動したメイン側のTclグローバル変数の値を取得します
スレッドプロシージャ,スクリプトの中でのみ有効です
互換性維持のために残存しています。このコマンドを使わなくてもグローバル変数にアクセスできます。

参照
api thread
api threadEval
api exitThread

getviewer

api getViewer $filename

return path

指定したファイルを表示するプログラム名をフルパスで返します
プログラム名が不明の場合やファイルが見つからなかった場合は空文字が返ります
$filenameには絶対パスでファイル名を与えます
そのファイルは現存している必要があります

参照: api shellopen

getlasterror

api getLastError

return errno

OSのプログラムがエラー終了した時のエラー番号を返します

参照: api errorString

http.get

api http.get $url [$username [password]]

return text

wininet api

winInet API

コマンドシーケンス

HTTP GET
api inet.open
api inet.connect
api inet.httpRequest
api inet.read
api inet.close

HTTP POST (Normal size)
api inet.open
api inet.connect
api inet.httpRequest
api inet.read
api inet.close

HTTP POST (Large size)
api inet.open
api inet.connect
api inet.httpRequest
api inet.write
api inet.read
api inet.close

FTP get
api inet.open
api inet.connect
api inet.ftpOpenFile
api inet.read
api inet.close

FTP put
api inet.open
api inet.connect
api inet.ftpOpenFile
api inet.write
api inet.close

=====================================================

api inet.open

return session

wininetインスタンスを作成してセッションハンドルを返します
http/ftp共通コマンドです

api inet.close $session [$connect]

wininetのハンドルを削除します
http/ftp共通コマンドです

$session : api inet.openで返されたハンドル
$connect : api inet.connectで返されたハンドル

api inet.connect $session [$server [$service [$port [$username [$password]]]]]

return connect

サーバーに接続してコネクションハンドルを返します
http/ftp共通コマンドです

$session : api inet.openで返されたハンドル
$server : サーバー名 例:"freesoftnet.co.jp"
$service : サービス名 {http | ftp}
$port : TCPポート番号(16進数)
$username: ユーザー名(ftp)
$password: パスワード(ftp)

api inet.httpRequest $connect $url [$method [$post_len [$postdata]]]

return request

サーバーに送信するHTTPリクエストを作成して送信し、そのリクエストハンドルを返します
http専用コマンドです

$connect : api inet.connectで返されたセッションハンドル
$url : ファイルパス 例:"http://https:reesoftnet.co.jp/index.htm"
$method : {GET | POST | HEAD} 省略時:"GET"
$post_len: POSTデータのバイトサイズ
$postdata: POSTするデータ 巨大サイズの場合は省略する($post_lenだけ)
その代わりapi inet.writeで送信する

api inet.httpOpenFile $session $url

return request

サーバーにファイルをGETするHTTPリクエストを送信しそのリクエストハンドルを返します
http専用コマンドです

$session : api inet.openで返されたハンドル
$url : ファイルパス 例:"http://https:reesoftnet.co.jp/index.htm"

api inet.ftpOpenFile $connect $filename [$rw [$binary]]

return request

サーバーのファイルをオープンしリクエストハンドルを返します
ftp専用コマンドです

$connect : api inet.connectで返されたコネクションハンドル
$filename: ファイル名 例:"userlist.dat"
$rw : アクセスモード 'r' か 'w' 省略時:r
/ $binary : バイナリモードなら1を与えます 省略時:1

api inet.read $request

return data

サーバーのファイルを読み込みます
http/ftp共通コマンドです

$request : 下記コマンドで返されたハンドル
api inet.httpRequest
api inet.httpOpenFile
api inet.ftpOpenFile

api inet.write $request $data $length [post]

return wrotesize

サーバーのファイルに書き込みます
書き込んだデータのバイトサイズを返します
-1が返ったらエラーです

巨大サイズのPOSTデータはこのコマンドで送信します
その場合はアーギュメント末尾に"post"を加えて下さい

http/ftp共通コマンドです

$request : 下記コマンドで返されたハンドル
api inet.ftpOpenFile
api inet.httpRequest
$data : 書き込むデータ
$length : $dataのバイトサイズ

inport

api inPort $port_number

return val

I/Oポートから1バイト読み込みます(外部入力)
参照:api outPort

japanese

api japanese

return true

OSが日本語OSなら1を返します

jis2sjis

api jis2sjis $jis

return sjis

JISコード文字列をShft-JISコード文字に変換します

参照: api sjis2jis

killtimer

api killTimer $id

イベントタイマを削除します
$id : タイマID

参照: api setTimer

kill

api kill $pid

プロセスを強制終了します
$pid : プロセスID

参照:
api exec
api wait

myhostname

api myHostName

return hostname

コンピュータのDOMAIN名を返します

使用例:
api myHostName
→yoshida3
api getIPaddress yoshida3
→192.168.100.16
api getHostName 192.168.100.16
→yoshida3.local
api getComputerName
→YOSHIDA3
api getIPaddress YOSHIDA3
→192.168.100.16

myipaddress

api myIPaddress

return ipaddress

コンピュータのIPアドレスを返します

使用例:
api myIPadddress
→192.168.100.16
api myHostName
→yoshida3
api getIPaddress yoshida3
→192.168.100.16
api getIPaddress localhost
→127.0.0.1

mkdir

api mkDIR $newdirname

return success

新しいフォルダを作成します

mkfile

api mkFILE $filename

return success

新しい空ファイルを作成します
作成するだけです。同期処理などに活用します。

outport

api outPort $port_number $outval

return success

ポートに1バイト出力します(外部出力)

参照: api inPort

open

api open $filename [$mode]

return $path

ファイルをファイルハンドルを返します
modeを省略するとrbで開きます
mode: c関数 fopen()のmode です。ただしtは不可です。

参照:
api close
api seek
api tell
api gets
api read
api eof

read

api read $fp $size

return data

reg

api reg set $hkey $key [$varname] $val

api reg get $hkey $key [$varname]

return val

api reg setはレジストリに値をセットします
api reg getはレジストリから値を読み込みます

値のセットではキーの作成もできます
$varnameは省略可能な変数名です

rgb

api rgb $red $green $blue

return COLORREF

COLORREF値を返します

seek

api seek $path $address [$origin]

return newadr

ファイルポインタを移動します
移動後の位置が返ります(ファイル先頭からの位置)

$path : api openで返されたファイルハンドル
$adddress : 移動バイト数
$origin : 移動原点
"set" : 先頭から
"current" : 現在位置から
"end" : 末尾から

参照:
api open
api close
api seek
api tell

scanfile

api scanFile [$posix] [dir]

return filelist

$posixの条件でファイルをスキャンしてファイル名リストを返します
$posixを省略すると"*.*"指定と見なされます
"dir"を与えるとフォルダリストを返します

使用例:
foreach file [api scanFile *.exe] {
.....
}

sjis2jis

api sjis2jis $sjis

return jis

Shift-JIS漢字をJIS漢字に変換して返します

参照:api jis2sjis

sjis2hex

api sjis2hex $sjis

return jis

Shift-JIS漢字を%HEX変換して返します

参照:
api jis2sjis
api sjis2jis

sjisucshex

api SjisUcsHex $sjis

return ucshex

Shift-JIS漢字列をUCSHEXコードに変換します

UCSHEXコードはShift-JIS漢字コードをユニコードに変換し、
それらを16進数表記することでASCII文字列化したコードです
漢字コードを表す16進数部はコードで挟まれます

sjis

api sjis $char

return true

$charがShift_JISの先頭バイトか否かを返します

splitutfhex

api SplitUtfHex $utf

return ucshex_list

shortcut

api shortcut $exefilename $lnkfilename $workfolder $comment

api shortcut $exefilename $lnkfilename $workfolder $comment $minimumwindow_onoff

api shortcut $exefilename $lnkfilename $workfolder $comment $iconname $index $minimumwindow_onoff

wait

api wait $pid

return exitcode

api execで起動したプロセスの終了を待ちます
$pidにはapi execの戻り値を与えます
エラーがあった場合はエラーコードが返されます