使用Scan From String、Format into String、Spreadsheet String to Array、Array to Spreadsheet String 等VI都有接角Format String,可以依照輸入的Format格式做客製化更改。這篇介紹如何使用Format String和其範例。
因為Format的功能眾多,就以列表展示Format String的類別和應用範例:
以上為圖片檔,因為本來使用文字檔,但是讀者反映看不到文字,所以特地加上圖片檔。
以下文字檔為全表,方便讀者複製內文,內文和上面圖表一模一樣:
Syntax Element |
說明 |
使用方法字串範例 |
範例 |
|
輸入 |
輸出 |
|||
s |
基本字元,前加數字代表限制的字元數量 |
%3s |
|
|
f |
浮點數,前加數字代表限制的字元數量 |
%2.3f |
|
|
d |
整數,前加數字代表限制的字元數量 |
%3d |
|
|
$ |
改變順序(Order) |
%2$s %1$s |
|
|
+ |
顯示其數直正負(+、-)符號 |
%+d |
|
|
e |
工程顯示 |
%.3e |
|
|
^ |
工程顯示,指數顯示為3倍數 |
%^.3e |
||
文字中不包括 |
%[^,],%s |
|
|
|
^;]%s |
|
|||
%[^0-9] |
|
|
||
[ ] |
數字字元 |
%[0-9] |
||
英文字元 (大小寫有區隔) |
%[0-9]%[a-z] |
|
||
轉換代碼 |
x,十六進位 |
%02x |
12 |
0C |
o,八進位 |
%06o |
12 |
000014 |
|
b,二進位 |
%b |
12 |
1100 |
|
相對時間t |
輸入為秒數 |
%.2t |
|
|
%<Hours:%H Minutes:%M Seconds:%S>t |
|
|||
絕對時間T |
輸入的時間格式必須正確 |
%<%.3X %x>T |
00:00:00.000 AM |
12:00:00.000 AM 01/01/2001 |
%<%Y.%m.%d>T |
00:00:00.000 AM |
2001.01.01 |
如果覺得文章有幫助,請不要吝嗇按下側邊的廣告唷~ 謝謝~
學習相關LabVIEW文章:
程式分享相關LabVIEW文章:
考取LabVIEW證照相關:
留言列表