以下的 pro 檔頭的說明文件,提供您需不需要下載的參考。
如果有任何使用上的問題或意見,請回應,謝謝。
;;======================================
;; hexnum.pro 自動加流水號 十六進制版本 v1.00 【漢書Profile】he6.00+
;;
;; 1999.04.21 (c) by 李棟樑 <dllee@edirect168.com> http://dllee.ktop.com.tw
;;======================================
;;
;; ■ 目的
;;
;; 在漢書中有內建自動加流水號的弁遄A不過只有提供十進制的流水號。對於程式
;; 寫作來說常常需要使用到十六進制的流水號,所以筆者建立此一巨集來補內建
;; 巨集的不足
;;
;; ■ 安裝方法
;;
;; 您可以選擇以下任一種安裝方法:
;;
;; 1. 如果您沒有自己定義 my.pro 可以直接將本檔案改名成 my.pro 放在漢書的
;; 安裝目錄即可。
;;
;; 2. 如果您有自己定義 my.pro ,請在 my.pro 的 def autoexec 中加入以下的
;; 設定
;;
;; def autoexec=[exist hexnum.pro]
;; [if %Exist][m hexnum.pro][end]
;;
;; 如果您還沒有定義 autoexec 則直接將上面一行文字去掉前面的空白及註解 ;;
;; 貼到您的 my.pro 中即可。
;; 如果您已定義 autoexec 則將上述的定義加在您原本 autoexec 定義之後即可。
;;
;; ■ 定義巨集指令
;;
;; hex2int1 %1 將 %1 字串的第一個字(十六進制的數) 轉成十進制
;; int2hex1 %1d 將 %1d (0~15 十進制的數) 轉成一位十六進制 0~F
;; hex2int %1 將 %1 字串(十六進制的數) 轉成十進制
;; int2hex %1 %2 將十進位整數轉為十六進制,轉換結果放在 %@HexResult
;; 用法: [int2hex 整數 位數]
;; hnumber 自動加十六進制流水號長度 4 的十六進位,由 0x0001
;; 開始每次加 1
;;
;;
;; ■ 使用方法
;;
;; 基本上是參考原來的 【 自動加流水號 】:
;;
;; 1. 無標示則全檔加流水號
;; 2. 有標示則標示行加流水號
;; 3. [number]:由 1 開始每次加 1
;; 4. [number n1]:由 n1 開始每次加 1
;; 5. [number n1 n2 :]:由 n1 開始每次加 n2,流水號之後都加上:。
;;
;; 在十六進制版本中則將指令命名為 hnumber ,並多了一個長度 L 的設定:
;;
;; 【 自動加流水號 十六進制版本 】
;; 1. 無標示則全檔加流水號
;; 2. 有標示則標示行加流水號
;; 3. [hnumber]:長度 4 的16進位,由 0x0001 開始每次加 1
;; 4. [hnumber L]:長度 L 的16進位,由 0x0001 開始每次加 1
;; 5. [hnumber L n1]:長度 L 的16進位,由 n1 開始每次加 1
;; 6. [hnumber L n1 n2 :]:長度 L 的16進位,由 n1 開始每次加 n2,
;; 流水號之後都加上:。
;;
;; 如: [hnumber 4 0xA000] 長度 4 的16進制,由 0xA000 開始每次加 1
;; [hnumber 4 A000] 長度 4 的16進制,由 0xA000 開始每次加 1
;; [hnumber 5 A000 2] 長度 5 的16進制,由 0xA000 開始每次加 2
;;
;;======================================
;; 1999.04.21(c)v1.00 by 李棟樑<dllee@edirect168.com> http://dllee.ktop.com.tw
;;======================================
[Profile] 自動加流水號 十六進制版本
[Profile] 自動加流水號 十六進制版本
- 附加檔案
-
- hexnum.pro
- 自動加流水號 十六進制版本
- (8.89 KiB) 已下載 155 次
因為此討論區不能夾檔,直接把 pro 檔都放上來好了,用需要的請
代碼: 選擇全部
;;======================================
;; hexnum.pro 自動?#91;流水號 十六進制版本 v1.00 【漢書Profile】he6.00+
;;
;; 1999.04.21 (c) by 李棟樑 <dllee@edirect168.com> http://dllee.ktop.com.tw
;;======================================
;;
;; ■ 目的
;;
;; 在漢書中有內建自動?#91;流水號的功能,不過只有提供十進制的流水號。對於?#123;式
;; 寫作來說常常需要使用到十六進制的流水號,所以筆者建立此一巨集來補內建
;; 巨集的不足
;;
;; ■ 安裝方法
;;
;; 您可以選擇以下任一種安裝方法:
;;
;; 1. 如果您沒有自己定義 my.pro 可以直接將本檔案改名成 my.pro 放在漢書的
;; 安裝目錄即可。
;;
;; 2. 如果您有自己定義 my.pro ,請在 my.pro 的 def autoexec 中?#91;入以下的
;; ?#93;定
;;
;; def autoexec=[exist hexnum.pro]
;; [if %Exist][m hexnum.pro][end]
;;
;; 如果您還沒有定義 autoexec 則直接將上面一行文字去掉前面的空白及註解 ;;
;; 貼到您的 my.pro 中即可。
;; 如果您已定義 autoexec 則將上述的定義?#91;在您原本 autoexec 定義之後即可。
;;
;; ■ 定義巨集指令
;;
;; hex2int1 %1 將 %1 字串的第一個字(十六進制的數) 轉成十進制
;; int2hex1 %1d 將 %1d (0~15 十進制的數) 轉成一位十六進制 0~F
;; hex2int %1 將 %1 字串(十六進制的數) 轉成十進制
;; int2hex %1 %2 將十進位整數轉為十六進制,轉換結果放在 %@HexResult
;; 用法: [int2hex 整數 位數]
;; hnumber 自動?#91;十六進制流水號長度 4 的十六進位,由 0x0001
;; ?#125;始每次?#91; 1
;;
;;
;; ■ 使用方法
;;
;; 基本上是參考原來的 【 自動?#91;流水號 】:
;;
;; 1. 無標示則全檔?#91;流水號
;; 2. 有標示則標示行?#91;流水號
;; 3. [number]:由 1 ?#125;始每次?#91; 1
;; 4. [number n1]:由 n1 ?#125;始每次?#91; 1
;; 5. [number n1 n2 :]:由 n1 ?#125;始每次?#91; n2,流水號之後都?#91;上:。
;;
;; 在十六進制版本中則將指令命名為 hnumber ,並多了一個長度 L 的?#93;定:
;;
;; 【 自動?#91;流水號 十六進制版本 】
;; 1. 無標示則全檔?#91;流水號
;; 2. 有標示則標示行?#91;流水號
;; 3. [hnumber]:長度 4 的16進位,由 0x0001 ?#125;始每次?#91; 1
;; 4. [hnumber L]:長度 L 的16進位,由 0x0001 ?#125;始每次?#91; 1
;; 5. [hnumber L n1]:長度 L 的16進位,由 n1 ?#125;始每次?#91; 1
;; 6. [hnumber L n1 n2 :]:長度 L 的16進位,由 n1 ?#125;始每次?#91; n2,
;; 流水號之後都?#91;上:。
;;
;; 如: [hnumber 4 0xA000] 長度 4 的16進制,由 0xA000 ?#125;始每次?#91; 1
;; [hnumber 4 A000] 長度 4 的16進制,由 0xA000 ?#125;始每次?#91; 1
;; [hnumber 5 A000 2] 長度 5 的16進制,由 0xA000 ?#125;始每次?#91; 2
;;
;;======================================
;; 1999.04.21(c)v1.00 by 李棟樑<dllee@edirect168.com> http://dllee.ktop.com.tw
;;======================================
%@hnum=0
def hex2int1= [stricmp %1 0 1] [if %Result==0] [%@hnum=0] [enddef] [end]
[stricmp %1 1 1] [if %Result==0] [%@hnum=1] [enddef] [end]
[stricmp %1 2 1] [if %Result==0] [%@hnum=2] [enddef] [end]
[stricmp %1 3 1] [if %Result==0] [%@hnum=3] [enddef] [end]
[stricmp %1 4 1] [if %Result==0] [%@hnum=4] [enddef] [end]
[stricmp %1 5 1] [if %Result==0] [%@hnum=5] [enddef] [end]
[stricmp %1 6 1] [if %Result==0] [%@hnum=6] [enddef] [end]
[stricmp %1 7 1] [if %Result==0] [%@hnum=7] [enddef] [end]
[stricmp %1 8 1] [if %Result==0] [%@hnum=8] [enddef] [end]
[stricmp %1 9 1] [if %Result==0] [%@hnum=9] [enddef] [end]
[stricmp %1 A 1] [if %Result==0] [%@hnum=10] [enddef] [end]
[stricmp %1 B 1] [if %Result==0] [%@hnum=11] [enddef] [end]
[stricmp %1 C 1] [if %Result==0] [%@hnum=12] [enddef] [end]
[stricmp %1 D 1] [if %Result==0] [%@hnum=13] [enddef] [end]
[stricmp %1 E 1] [if %Result==0] [%@hnum=14] [enddef] [end]
[stricmp %1 F 1] [if %Result==0] [%@hnum=15] [enddef] [end]
[%@hnum=-1]
%@hchar=""
def int2hex1= [if %1d ==0] [%@hchar="0"] [enddef] [end]
[if %1d ==1] [%@hchar="1"] [enddef] [end]
[if %1d ==2] [%@hchar="2"] [enddef] [end]
[if %1d ==3] [%@hchar="3"] [enddef] [end]
[if %1d ==4] [%@hchar="4"] [enddef] [end]
[if %1d ==5] [%@hchar="5"] [enddef] [end]
[if %1d ==6] [%@hchar="6"] [enddef] [end]
[if %1d ==7] [%@hchar="7"] [enddef] [end]
[if %1d ==8] [%@hchar="8"] [enddef] [end]
[if %1d ==9] [%@hchar="9"] [enddef] [end]
[if %1d ==10] [%@hchar="A"] [enddef] [end]
[if %1d ==11] [%@hchar="B"] [enddef] [end]
[if %1d ==12] [%@hchar="C"] [enddef] [end]
[if %1d ==13] [%@hchar="D"] [enddef] [end]
[if %1d ==14] [%@hchar="E"] [enddef] [end]
[if %1d ==15] [%@hchar="F"] [enddef] [end]
[%@hchar=" "]
%@HexResult="0000"
%@IntResult=0
def hex2int=[%@IntResult=0][%spos=1]
[if %ArgvNo >= 1]
[strlen %1][%slen=%Len] [%spos=1] ;; -------- '<字串長度 '"%Len"' >'
[strmiddle %1 2 1]
[stricmp %String X 1] ;; 若是使用 0x 則由 0x 之後?#125;始轉換
[if %Result==0] [%spos=3] [end]
[stricmp %String H 1] ;; 若是使用 0h 則由 0h 之後?#125;始轉換
[if %Result==0] [%spos=3] [end]
[do %j=%spos ; %j <= %Len ; %j=%j+1]
[%@IntResult=%@IntResult*16]
[strmiddle %1 %j 1]
[hex2int1 %String] ;; -------- '<字元 '"%String"' = '"%@hnum"' >'
[if %@hnum < 0 ] [break]
[else] [%@IntResult=%@IntResult+%@hnum]
[end]
[end]
[end]
;;
;; int2hex 將10進位整數轉為16進制,轉換結果放在 %@HexResult
;; 用法: int2hex 整數 位數
;;
def int2hex=[if %1d<= 0] [%@HexResult="0"] [else] [%@HexResult=""] [end]
[do %int=%1d ; %int > 0 ; %int=%int]
[cal %int/16] ;;--------- '< 計算結果:%CalResult '
[strstr %CalResult e] ;; 最後一位,?#93;為除以16的結果太小,在結果中以 R e-N 來表示
[if %Found==1]
;;--------- '最後一位!>'
[int2hex1 %int]
[%@HexResult="%@hchar%@HexResult"]
[break]
[end]
[strstr %CalResult .]
[if %Found==1] ;; 不整除
[strleft %CalResult %Len-1]
[atod %String]
[%tint=%int - %Result*16] ;; --------- '餘數:'"%tint"'> '
[int2hex1 %tint]
[%@HexResult="%@hchar%@HexResult"]
[%int=%Result]
[else] ;; 整除
[%@HexResult="0%@HexResult"] ;; --------- '整除!>'
[%int=%int/16]
[end]
[end]
[if %1d < 16 ] [%hexstrlen=1] ;; strlen 在不同的數值還會有不同的狀況
[elseif %1d < 256 ] [%hexstrlen=2] ;; 應該算是 bug 如: ECF 游標會跳到 TOP
[elseif %1d < 4096 ] [%hexstrlen=3] ;; 改成用數值直接判斷資料長度
[elseif %1d < 65536 ] [%hexstrlen=4]
[elseif %1d < 1048576 ] [%hexstrlen=5]
[elseif %1d < 16777216 ] [%hexstrlen=6]
[elseif %1d < 268435456 ] [%hexstrlen=7]
[elseif %1d < 4294967296 ] [%hexstrlen=8]
[elseif %1d < 68719476736 ] [%hexstrlen=9] [end]
[do %k=%hexstrlen+1 ; %k <= %2d ; %k=%k+1] ;; 補足長度
[%@HexResult="0%@HexResult"]
[end]
%@HexLastNumber=0
def hnumber=[message Waiting ...][redraw]
[if %MarkType=="BLOCKMARK"][replace mode][else][insert mode][end]
[cursor data][%start=1] [%inc=1][%hlen=4]
[if %ArgvNo >= 4] [%hlen=%1d] [hex2int %2] [%start=%@IntResult] [%inc=%3d] [end]
[if %ArgvNo >= 3] [%hlen=%1d] [hex2int %2] [%start=%@IntResult] [end]
[if %ArgvNo >= 2] [%hlen=%1d] [end]
[if %Mark] [begin mark][begin line][begin mark][else][top][begin line] [end]
[%startline=%Line]
[do %i=%start; ; %i=%i+%inc]
[int2hex %i %hlen]
"0x%@HexResult"[if %ArgvNo==5]"%4"[end]
[if %MarkType=="BLOCKMARK"][column %LeftMark]
[else][line tab][begin line] [end]
[if (%Mark && %Line >= %BottomMark) || %Line >= %Lines] [break] [end]
[line %Line+1]
[if %Char == "─"][line %Line+1][end]
[end][%@HexLastNumber=%i+1][%i = %i - %start + 1]
[%plines=%Line-%startline+1]
[if %i == %plines]
[message 共轉換 %i 個]
[else]
[beep][message 錯誤!! 共有 %plines 行,卻轉換了 %i 次!!][beep]
[end]
沒空更新的網頁...
http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....