通訊埠印表機
# FastWeb 通訊埠印表機
# 1. 說明
本範例採用通訊埠通訊協議,控制通訊埠印表機進行列印輸出。通過向通訊埠輸入特定列印指令的字元,印表機對指令進行解析並列印出所需的內容。目前市面上的一些帶有通訊埠的標籤印表機使用的是TSPL(TSC標籤印表機的通訊埠列印程式語言),通過通訊埠輸入的內容需按照TSPL的規範進行。
本範例使用到的是佳博GP-3120TN標籤印表機,該印表機帶有一個通訊埠介面,可用於接收TSPL指令進行列印操作,其外觀如下圖所示。
在使用前,先將USB通訊埠轉接線的通訊埠端與標籤印表機的通訊埠端連線,再將USB端與PC進行連線。印表機通電並打開印表機的電源開關,待PC端確認設備連線后,在Windows的設備管理器中檢視連線的通訊埠埠號以及通訊埠設備的名稱,該埠號會在接下來的範例中使用到。
通過本範例學習,可以掌握 TUgWebSerial
元件的基本屬性,以及通過通訊埠進行列印操作的方法。目前為止,通過Web通訊埠列印的方式僅支援英文字元的列印,暫不支援簡體中文字元的列印。
# 2. 設計明細
開啟FastWeb設計器,分別加入下插圖之控制元件。或者點選左上角的[匯入]
選擇模板檔案來打開對應模板。
1:TUgLabel元件,控制元件名稱為UgLabel01
。
2:TUgMemo元件,控制元件名稱為 UgMemo01
。
3:TUgWebSerial元件,控制元件名稱為 UgWebSerial01
。
4:TUgSVG元件,控制元件名稱為 UgSVG01
。
5:TUgIconClsList元件,控制元件名稱為 UGIconClsList01
。
6:TUgFSButton元件,控制元件名稱為 UgFSButton02
。
7:TUgFSButton元件,控制元件名稱為 UgFSButton01
。
UgWebRunFrame屬性設定
Height
:設定頁面高度=480
。Width
:設定頁面寬度=640
。
1:UgLabel01屬性設定
Alignment
:設定對齊方式,設定為taCenter
。AutoSize
:設定控制元件尺寸是否跟隨文字自動變化,設定為False
。Font
:設定字型,點選右側的[√]
打開字型編輯視窗,按照下圖的樣式進行設定。
Text
:設定標籤顯示的文字=通訊埠印表機
。
4:UgSVG01屬性設定
HTML
:設定印表機的背景影象,將以下文字填寫至其中。
<?xml version="1.0"encoding="UTF-8"?><svg viewBox="0 0 473.40576 483.51993"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"><defs><filter id="h"><feGaussianBlur stdDeviation=".47443"/></filter><filter id="g"x="-.2063"y="-.03511"width="1.4126"height="1.0702"><feGaussianBlur stdDeviation=".96686"/></filter><linearGradient id="a"><stop stop-color="#c0c2bf"offset="0"/><stop stop-color="#dddfdc"offset="1"/></linearGradient><linearGradient id="f"x1="412.24"x2="412.99"y1="18.589"y2="11.532"gradientUnits="userSpaceOnUse"><stop stop-color="#9fa09a"offset="0"/><stop stop-color="#e0e2df"offset="1"/></linearGradient><linearGradient id="e"x1="307.86"x2="425.48"y1="391.49"y2="396.01"gradientUnits="userSpaceOnUse"><stop stop-color="#999894"offset="0"/><stop stop-color="#bcbcba"offset="1"/></linearGradient><linearGradient id="d"x1="328.57"x2="383.28"y1="389"y2="384.28"gradientUnits="userSpaceOnUse"><stop stop-color="#91918c"offset="0"/><stop stop-color="#bfc0bb"offset="1"/></linearGradient><radialGradient id="c"cx="376.45"cy="191.25"r="57.593"gradientTransform="matrix(.41373 .09822 -.06423 .27056 232.99 102.53)"gradientUnits="userSpaceOnUse"xlink:href="#a"/><radialGradient id="b"cx="227.8"cy="166.08"r="52.365"gradientTransform="matrix(.73431 .14932 -.06128 .30135 79.9 78.449)"gradientUnits="userSpaceOnUse"xlink:href="#a"/></defs><g transform="translate(-12.138 -2.3946)"><path d="m388.66 199.02-6.51 8.2021 50.016 30.561c5.839-5.4262 11.775-10.738 17.756-16.077 2.4605-2.1965-1.5463-6.8904-4.7624-7.7411l-56.5-14.945z"fill="#dfe0db"/><path d="m103.46 346.27-10.832-48.881 231.77 53.741-0.55546 57.213-220.38-62.073z"fill="#2e2f2a"/><path d="m84.778 365.78c0.29188-5.1863-1.1354-9.8568 6.1796-17.15l5.0686 7.6376-11.248 9.5123z"fill="#a8a9a3"/><path d="m96.512 293.78-16.247-5.1381 10.554 60.823c0.79958 4.6081 6.3041 6.5401 10.415 8.0542l3.4717-14.442-8.1931-49.298z"fill="#a3a49e"/><path d="m96.512 293.78-16.247-5.1381"fill="none"stroke="#7b7b71"/><path d="m91.131 348.39c0.45241 4.8164 5.9916 7.6164 10.103 9.1304"fill="none"stroke="#7e7e76"/><path d="m326.34 411.4c-19.028 25.742-38.023 41.876-54.927 54.193-9.2919 6.7703-18.178 12.914-27.281 16.906-8.9476 3.9236-14.909 3.6787-22.774 3.0551l-200.52-62.768c-2.9084-0.9104-8.8721-3.4242-8.6873-8.2258 0.13549-3.5209 5.3545-5.1054 5.3545-5.1054 27.318-7.0766 61.512-35.682 88.319-64.156l218.85 59.712c2.5975 0.70872 3.12 4.4214 1.6664 6.3878z"fill="#c8c8c6"/><path d="m332.45 422.93-11.248-4.0271 3.3328-62.073 7.9154 66.1z"filter="url(#g)"/><path d="m307.01 89.48 51.42-78.39 118.59 18.148-47.765 82.801-122.25-22.559z"fill="#e1e3e0"/><path d="m477.57 29.386-47.891 83.053 47.891-83.053z"fill="none"stroke="#916f6f"/><path d="m479.67 19.156-119.6-16.762c-2.4736 2.3424-2.9874 5.2194-1.7644 8.57l119.1 18.274"fill="url(#f)"/><path d="m483.07 29.491-3.4028-9.9563s-4.1782 6.5609-2.6466 9.4522c1.2808 2.4178 6.0494 0.50411 6.0494 0.50411z"fill="#a4a9a5"/><path d="m445.24 214.97 39.192-80.007c3.443-7.0286-1.7622-13.592-6.8376-20.763 1.5335 4.3014 2.176 7.3048 0.0648 10.96l-48.898 84.662 16.478 5.148z"fill="#aeafaa"/><path d="m303.95 88.945 2.7652-5.2829c1.5354 0.43812 1.6199 1.949 2.276 3.2664l-1.7014 2.4576-3.3398-0.4411z"fill="#bdbfba"/><path d="m199.42 168.15 52.338-83.611c5.0515-8.07 11.007-8.59 17.037-7.5486l37.997 6.5618-2.8392 5.3722 125.92 23.029 3.6117-6.03 44.129 8.2196c1.5335 4.3014 2.1333 7.351 0.0423 11.018l-51.012 89.462-227.23-46.472z"fill="#dfe1de"/><g fill="none"stroke="#000"><path transform="matrix(.9925 0 -.47327 .96802 44.238 1.9354)"d="m271.28 90.016c0 3.2192-2.6802 5.8288-5.9864 5.8288s-5.9864-2.6097-5.9864-5.8288 2.6802-5.8288 5.9864-5.8288 5.9864 2.6097 5.9864 5.8288z"stroke-linecap="round"stroke-linejoin="round"stroke-width="1.0202"/><path d="m267.08 93.256-4.2776-8.5551"/></g><g fill="none"stroke="#000"><path transform="matrix(1.0773 0 -.32455 .914 27.918 10.051)"d="m271.28 90.016c0 3.2192-2.6802 5.8288-5.9864 5.8288s-5.9864-2.6097-5.9864-5.8288 2.6802-5.8288 5.9864-5.8288 5.9864 2.6097 5.9864 5.8288z"stroke-linecap="round"stroke-linejoin="round"stroke-width="1.0078"/><path d="m286.42 96.821-4.0102-8.9116"/></g><path d="m372.01 124.13 10.248-16.665"fill="none"stroke="#000"stroke-width="1.6"/><path d="m420.36 131.22 9.0898-15.684"fill="none"stroke="#000"stroke-width="1.6"/><text transform="matrix(.98086,.24341,-.53832,.88592,0,0)"x="444.06216"y="12.40039"font-family="Bitstream Vera Sans"font-size="5.4641"><tspan x="444.06216"y="12.40039"dx="0 -0.20051065"dy="1.7120309e-009 -0.11139476">A5</tspan></text><path d="m449.14 137.55 10.07-16.932"fill="none"stroke="#000"stroke-width="1.3"/><text transform="matrix(.98086,.24341,-.53832,.88592,0,0)"x="473.2843"y="10.10517"font-family="Bitstream Vera Sans"font-size="5.4641"><tspan x="473.2843"y="10.10517"dx="0"dy="0">A4</tspan></text><path d="m452.26 137.9 6.3272-10.605"fill="none"stroke="#000"stroke-width="1.3"/><text transform="matrix(1.0422 .18673 -.23945 .91657 0 0)"x="451.97604"y="50.28987"font-family="Bitstream Vera Sans"font-size="5.3466"><tspan x="451.97604"y="50.28987"dx="0 -0.31190538">LTR</tspan></text><text transform="rotate(8.7886)"x="337.47696"y="60.5989"font-family="Bitstream Vera Sans"font-size="3.9881"><tspan x="337.47696"y="60.5989">Face Down</tspan></text><g transform="matrix(.89039 .38057 -.47649 .91945 134.57 -128.46)"fill="none"stroke="#000"><g transform="translate(-.0549)"><path d="m318.8049,130.78638v-5.76581c0-.32329.2116-.56713.53634-.56713h1.96918v12.66588h-9.01104v-5.561c0-.49758.19415-.77194.72467-.77194h5.78085z"stroke-linecap="round"stroke-width=".5"/><path d="m317.66 130.19v-4.474"/><path d="m315.66 130.19v-2.4733"/><path d="m313.66 130.19v-0.51988"/></g><path d="m315.49 138.01v3.4624h-0.85094l1.04 1.0478 1.0716 1.0706 1.04-1.0706 1.0716-1.0478h-0.88246v-3.4624"stroke-linecap="round"stroke-width=".21435"/></g><path d="m361.1 136.03c0.86895-2.8598 1.7011-5.4944 4.2451-6.8466l-3.7104-2.065c-3.9427 2.0524-4.0933 5.3688-4.634 8.5551l4.0993 0.35647z"fill="#bdbfbe"stroke="#000"stroke-width=".25"/><path d="m356.28 135.61c0.11369-3.1369 0.34184-6.3629 4.0959-8.5069l-6.9316-0.69316c-2.7835 2.5436-3.5997 5.4807-3.0247 8.696l5.8603 0.50411z"fill="#ebecee"stroke="#000"stroke-width=".25"/><path d="m335.54 131.61c0.11369-3.1369 0.34184-6.3629 4.0959-8.5069l-6.9316-0.69316c-2.7835 2.5436-3.5997 5.4807-3.0247 8.696l5.8603 0.50411z"fill="#ebecee"stroke="#000"stroke-width=".25"/><path d="m367.63 133.59-4.348-1.1973"fill="none"stroke="#000"/><path d="m325.66 125.78-2.2685-0.50411"fill="none"stroke="#000"/><path d="m325.22 129.81c0.26931-2.638 0.88542-5.1026 3.1507-6.7425l2.6466 0.37808c-2.5341 2.3378-2.2529 5.469-2.0165 7.4357l-3.7809-1.0712z"fill="#bdbfbe"stroke="#000"stroke-width=".25"/><path d="m348.34 134.22c0.22844-2.5478 1.1398-4.9714 3.2137-7.1836l-9.7042-2.5836c-3.3202 2.1421-3.6717 5.0264-4.411 7.8138l10.901 1.9534z"fill="#bdbfbe"stroke="#000"stroke-width=".25"/><path transform="matrix(.95563,.29456,-.48336,.87542,0,0)"d="m369.49 19.322h4.0427v3.7384h-4.0427z"stroke="#000"stroke-linecap="round"stroke-width=".25267"/><path d="m325.45 174.17 19.071-31.547c1.4068-2.3272 3.1063-2.9483 6.4163-2.317l103.73 19.784-21.031 37.429-108.19-23.348z"fill="#dddddb"/><path d="m325.45 174.17 19.071-31.547c1.4068-2.3272 3.1063-2.9483 6.4163-2.317l103.73 19.784"fill="none"stroke="#8a8b85"stroke-width="1.5"/><path transform="rotate(11.161)"d="m361.26 85.83 110.35 0.15221-1.5073 4.3254-110.48 0.0019 1.6375-4.4795z"fill="#5d5e56"/><g transform="translate(.67001,.29385)"><path d="m427.87 208.07-108.76-23.567 6.1754-10.082 108.51 22.811-5.9234 10.838z"fill="url(#c)"/><path d="m427.87 208.07-108.76-23.567 108.76 23.567z"fill="none"stroke="#91928a"/></g><path d="m366.24 200.76 45.244-69.064c2.0407-3.115 5.1513-2.8501 7.0576-1.3863l7.0576 5.4192-29.743 53.058c-1.165-0.31215-2.2828-0.11696-3.1507 1.3863l-3.4028 6.0494c-0.9381 1.6248-0.8822 3.043-0.8822 3.9069l-3.5288 4.0329-18.652-3.4028z"fill="#bfc1be"/><path d="m366.24 200.76 45.244-69.064c1.1938-1.8223 2.7538-2.4878 4.2246-2.4334l-4.7997-2.2108c-1.7653-0.59989-2.9622 0.81863-4.0179 2.4022l-46.595 69.896 5.9437 1.4095z"fill="#e0e2e1"/><path d="m212.1 151.36 21.566-33.151 96.067 18.18c3.1276 0.59187 3.6957 2.9225 2.6735 4.4558l-21.744 32.616-98.562-22.101z"fill="#dcdcda"/><path d="m212.1 151.36 21.566-33.151 96.067 18.18c1.389 0.26285 2.2216 0.84003 2.6515 1.5475"fill="none"stroke="#8a8b85"/><path transform="rotate(11.917)"d="m247.45 82.825 101.93-1.2446-1.7018 4.3511-101.73 1.1102 1.5071-4.2166z"fill="#5d5e56"/><path d="m253.89 158.76 14.904 3.9638c1.2392 0.32956 2.2052-0.0745 2.8232-1.0607l19.078-30.44c0.53787-0.8582-0.13098-2.2949-1.1585-2.4952l-14.169-2.7626-21.477 32.795z"fill="#d7d7d7"/><path d="m253.51 158.67 15.282 4.0528c0.62075 0.16027 1.1709 0.14616 1.6445-0.0369"fill="none"stroke="#777870"/><path d="m270.44 162.68c0.47366-0.18309 0.86967-0.53065 1.1787-1.0237l19.078-30.44"fill="none"stroke="#bebfba"/><path d="m205.93 161.57 100.32 21.425s7.6612-8.6981 4.285-9.4522l-99.311-22.181-5.2932 10.208z"fill="url(#b)"/><path d="m205.93 161.57 100.32 21.425"fill="none"stroke="#91928a"/><path d="m229.74 167.94 43.132-61.668c1.3892-1.9862 4.6998-3.213 6.3272-1.8714l6.5946 5.4361-38.409 59.529-17.645-1.4259z"fill="#c0c2bf"/><path d="m229.74 167.94 43.132-61.668c0.86326-1.2342 2.4052-2.0799 3.6099-2.4672s-5.7382-1.3792-8.1222 0.48145l-44.039 63.133 5.4189 0.52125z"fill="#dfdfdf"/><path d="m327.55 186.77-6.8056-1.3863c-0.23666-5.5053 1.4358-8.2832 3.5288-10.46l7.3097 1.5124c-3.3656 2.7229-5.3536 5.9378-4.0329 10.334z"fill="#ebecee"stroke="#000"stroke-width=".25"/><path d="m305.75 182.11-5.9234-0.75618c-0.23666-5.5053 0.9317-8.2832 3.0247-10.46l6.5535 1.5124c-2.9632 2.8235-4.0757 5.5326-3.6548 9.7042z"fill="#ebecee"stroke="#000"stroke-width=".25"/><path d="m337.82 182.68-4.0959-1.1973"fill="none"stroke="#000"/><path d="m293.77 173.6 1.3863 0.4411"fill="none"stroke="#000"/><path d="m329.3 186.77h2.5206c-0.55173-4.119 1.0577-6.5818 3.1507-8.759l-1.6384-1.5754c-3.3656 2.7229-5.3536 5.9378-4.0329 10.334z"fill="#bdbfbe"stroke="#000"stroke-width=".25"/><path d="m294.61 178.96 4.285 1.1342c0.0154-4.434 0.4906-7.0229 2.5836-9.2001l-3.7178 0.31508c-2.3236 3.1433-2.3394 3.8172-3.1507 7.7508z"fill="#bdbfbe"stroke="#000"stroke-width=".25"/><path d="m319.67 183.62-12.162-2.8356c0.23503-3.1718 1.2692-5.8736 4.348-7.3727l9.9563 2.5206c-2.8673 3.1498-2.9487 5.5398-2.1425 7.6878z"fill="#bdbfbe"stroke="#000"stroke-width=".25"/><path transform="matrix(.95023,.31154,-.40087,.91614,0,0)"d="m359.01 68.65h5.2102v3.6087h-5.2102z"stroke="#000"stroke-linecap="round"stroke-width=".24232"/><path d="m375.77 306.7c20.406-36.741 45.986-61.139 74.155-84.986 9.1268 36.675 11.593 75.911 12.776 114.98l-75.543 82.764-13.331-100.54c-0.77019-4.3451-0.10482-8.3649 1.9441-12.22"fill="#bbbbb9"stroke="#a9aaa5"/><path d="m387.16 419.46-13.331-100.54c-0.3981-3.0023-0.38332-5.2089-0.0334-7.0891"fill="none"stroke="#84837e"/><path d="m308.36 432.03 11.53-13.022 12.388 4.0216 22.969 5.3125c8.2706 1.9086 19.227 2.1482 24.969-2.75l7-6 75.469-82.906-1.0139 55.112-82.549 50.471c-10.853 6.6356-23.332 3.8157-34.872 0.396l-35.889-10.636z"fill="url(#e)"/><path d="m367.84 445.44c-7.6542 0.77274-16.021-0.52509-23.591-2.7684l-35.889-10.636"fill="none"stroke="#908b85"/><path d="m313.28 426.48 6.6113-7.4668 12.388 4.0216 22.969 5.3125c8.2706 1.9086 19.227 2.1482 24.969-2.75-6.2986 6.5434-9.9524 15.056-32.217 9.7135l-34.72-8.8307z"fill="#aeafaa"/><path d="m380.22 425.59c-6.2986 6.5434-9.9524 15.056-32.217 9.7135l-34.72-8.8307"fill="none"stroke="#c7c6c2"/><path d="m377.26 348.41c-7.511 5.3305-13.963 11.663-26.316 9.8193l-26.316-3.9277 7.6591 68.735 22.977 5.3024c8.2706 1.9086 19.2 2.1487 24.941-2.7494l7.0208-5.9898-9.9666-71.19z"fill="url(#d)"/><path d="m377.26 348.41c-7.511 5.3305-13.963 11.663-26.316 9.8193l-26.316-3.9277 7.6591 68.735 22.977 5.3024c8.2706 1.9086 19.2 2.1487 24.941-2.7494l7.0208-5.9898"fill="none"stroke="#61625c"/><path d="m375.77 306.7c16.153-29.084 34.566-50.04 55.921-69.505-3.0123-11.23-5.4262-20.091-8.4736-24.037-3.8388-4.9708-60.48 75.43-61.476 77.906-4.4395 11.034-18.164 11.993-27.495 10.483-87.427-14.151-169.34-36.614-250.59-59.991-5.5532-1.5978-8.1397-4.5692-11.214-7.3516 1.2103 18.112 6.9099 36.937 7.6724 54.022l244.55 66.163 26.316 3.9277c12.353 1.8438 19.001-4.808 26.724-10.23l-3.8816-29.166c-0.77019-4.3451-0.10482-8.3649 1.9441-12.22z"fill="#a8a9a4"/><path d="m240.34 173.42-9.9563-3.4343s2.9447-2.298 6.7678-3.1604c2.5574-0.57684 6.0417-0.29483 7.2844-0.24241 1.3479 0.0569 4.9151 1.4178 4.9151 1.4178"fill="#e1e1df"/><path d="m246.95 175.31-6.8056-1.8904s5.2558-5.1053 8.633-5.3562c2.646-0.19662 7.3727 3.4028 7.3727 3.4028-1.9457 0.3737-7.6889-1e-3 -9.2001 3.8439z"fill="#bbbcb7"/><path d="m423.27 213.06c-6.5882-1.1413-60.529 75.381-61.525 77.857-4.4395 11.034-18.164 12.14-27.495 10.63-87.427-14.151-169.34-36.614-250.59-59.991-5.5532-1.5978-8.1397-4.5692-11.214-7.3516-0.82624-5.6393 1.4068-11.377 4.9407-16.176 15.204-20.645 31.454-40.484 51.436-57.454 10.762-6.2136 17.161-11.158 40.289-4.9606l254.16 57.446z"fill="#e0e0de"/><path d="m363.85 234.19 25.585 4.7064c2.4714 0.45462 2.9754 3.6616 1.5061 5.7001l-27.991 38.836c-1.4293 2.0668-3.9349 1.9859-6.6659 1.7613l-26.835-2.2068c-2.5044-0.20595-2.9573-3.6486-1.5061-5.7001l29.241-41.336c1.4512-2.0514 4.1945-2.2159 6.6659-1.7613z"fill="#667079"/><path transform="matrix(1 0 -.40247 1 105.42 -7.9154)"d="m356.89 247.44c0 1.1696-0.74607 2.1177-1.6664 2.1177s-1.6664-0.94813-1.6664-2.1177 0.74607-2.1177 1.6664-2.1177 1.6664 0.94813 1.6664 2.1177z"fill="#0f0"/><text transform="matrix(.95186,.21524,-.48092,.94183,0,0)"x="459.7312"y="151.12473"fill="#fff"font-family="Bitstream Vera Sans"font-size="4.2903"><tspan x="459.7312"y="151.12473">Ready</tspan></text><path transform="matrix(1 0 -.40247 1 99.447 -.27773)"d="m356.89 247.44c0 1.1696-0.74607 2.1177-1.6664 2.1177s-1.6664-0.94813-1.6664-2.1177 0.74607-2.1177 1.6664-2.1177 1.6664 0.94813 1.6664 2.1177z"fill="#500"/><text transform="matrix(.95186,.21524,-.48092,.94183,0,0)"x="457.75555"y="160.28178"fill="#fff"font-family="Bitstream Vera Sans"font-size="4.2903"><tspan x="457.75555"y="160.28178">Error</tspan></text><text transform="matrix(.95186,.21524,-.48092,.94183,0,0)"x="451.95477"y="166.76822"fill="#fff"font-family="Bitstream Vera Sans"font-size="4.2903"><tspan x="451.95477"y="166.76822">Start/Stop</tspan></text><path transform="matrix(1.2493 0 -.4047 1.2527 22.363 -64.914)"d="m361.15 267.3c0 4.6076-4.6051 8.3427-10.286 8.3427s-10.286-3.7352-10.286-8.3427 4.6051-8.3427 10.286-8.3427 10.286 3.7352 10.286 8.3427z"filter="url(#h)"stroke="#000"stroke-width=".25"/><path transform="matrix(1.2493 0 -.4047 1.2527 21.774 -65.7)"d="m361.15 267.3c0 4.6076-4.6051 8.3427-10.286 8.3427s-10.286-3.7352-10.286-8.3427 4.6051-8.3427 10.286-8.3427 10.286 3.7352 10.286 8.3427z"fill="#afd4cd"stroke="#394d4e"stroke-width=".25"/><path d="m311.62 347.94-5.4158-36.938c-1.9266 1.8691-3.212 4.288-3.9577 7.5682-0.66648 2.9317-0.74398 6.2301-0.34716 9.2346l2.9162 22.08c0.33808 2.5598 4.7095 6.8346 5.3464 4.166l1.4581-6.1101z"fill="#b8b8b6"/><path d="m91.997 269.35 5.1761-11.51c69.322 19.138 138.96 36.989 209.03 53.165-1.9266 1.8691-3.212 4.288-3.9577 7.5682-0.30831 1.3562-0.49058 2.7908-0.55816 4.2385-71.882-15.405-141.21-33.614-209.69-53.462z"fill="#babbb6"/><path d="m96.616 298.89-4.6192-29.539c64.762 18.582 135.66 37.708 209.69 53.462-0.0785 1.6819-2e-3 3.3814 0.211 4.9961l2.9162 22.08c0.18441 1.3962 1.5688 3.3027 2.8926 4.3143l-211.09-55.313z"fill="#93948e"/></g></svg>
15:UgIconClsList01屬性設定
雙擊以打開編輯器,按照下圖所示的內容新增兩項。
6:UgFSButton02屬性設定
Caption
:設定按鈕顯示的字幕資訊,設定為列印
。Images
:設定按鈕圖示繫結的圖形控制元件,設定為UGIconClsList01
。ImageIndex
:設定按鈕圖示在圖示列表中的序號,設定為1
。StyleButton
:設定按鈕的樣式,設定為GoogleBlueRound
。
7:UgFSButton01屬性設定
Caption
:設定按鈕顯示的字幕資訊,設定為打開通訊埠
。Images
:設定按鈕圖示繫結的圖形控制元件,設定為UGIconClsList01
。ImageIndex
:設定按鈕圖示在圖示列表中的序號,設定為0
。StyleButton
:設定按鈕的樣式,設定為GoogleGreenRound
。
# 3. 程式設計
點選程式設計界面右下角的按鈕,切換至單元選擇界面,勾選需要使用的單元。該程式的程式不需要引用單元。
# 3.1. 程式初始設定
該程式初始需設定要列印的指令字串。
//JScript
var s = "SIZE 40 mm,40 mm \\r\\n"+
"CLS \\r\\n"+
"TEXT 50,30,\"TSS24.BF2\",0,1,1,\"Item List\" \\r\\n"+
"TEXT 50,45,\"4\",0,1,1,\"--------------------\" \\r\\n"+
"TEXT 50,70,\"TSS24.BF2\",0,1,1,\"NOODLES 1 15 15 \" \\r\\n"+
"TEXT 50,100,\"TSS24.BF2\",0,1,1,\"POTATO 1 15 15 \" \\r\\n"+
"TEXT 50,130,\"TSS24.BF2\",0,1,1,\"KNIFE 1 15 15 \" \\r\\n"+
"TEXT 50,160,\"TSS24.BF2\",0,1,1,\"CHICKENS 1 15 15 \" \\r\\n"+
"TEXT 50,175,\"4\",0,1,1,\"--------------------\" \\r\\n"+
"TEXT 50,200,\"TSS24.BF2\",0,1,1,\"SUM 4 60 60 \" \\r\\n"+
"QRCODE 50,230,L,4,A,0,\"isoface.net\" \\r\\n"+
"PRINT 1 \\r\\n"+
"EOP";
{
ViewInit();
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//PasScript
Var s: string =
'SIZE 40 mm,40 mm \r\n'+
'CLS \r\n'+
'TEXT 50,30,"TSS24.BF2",0,1,1,"Item List" \r\n'+
'TEXT 50,45,"4",0,1,1,"--------------------" \r\n'+
'TEXT 50,70,"TSS24.BF2",0,1,1,"NOODLES 1 15 15 " \r\n'+
'TEXT 50,100,"TSS24.BF2",0,1,1,"POTATO 1 15 15 " \r\n'+
'TEXT 50,130,"TSS24.BF2",0,1,1,"KNIFE 1 15 15 " \r\n'+
'TEXT 50,160,"TSS24.BF2",0,1,1,"CHICKENS 1 15 15 " \r\n'+
'TEXT 50,175,"4",0,1,1,"--------------------" \r\n'+
'TEXT 50,200,"TSS24.BF2",0,1,1,"SUM 4 60 60 " \r\n'+
'QRCODE 50,230,L,4,A,0,"isoface.net" \r\n'+
'PRINT 1 \r\n'+
'EOP';
Begin
ViewInit;
End.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Make sure to add code blocks to your code group
設定初始化顯示的內容。
//JScript
function ViewInit()
{
ugWebSerial01.Visible = False;
UgMemo01.ReadOnly = True;
UgMemo01.Lines.Add("SIZE 40 mm,40 mm \\r\\n");
UgMemo01.Lines.Add("CLS \\r\\n");
UgMemo01.Lines.Add("TEXT 50,30,\"TSS24.BF2\",0,1,1,\"Item List\" \\r\\n");
UgMemo01.Lines.Add("TEXT 50,45,\"4\",0,1,1,\"--------------------\" \\r\\n");
UgMemo01.Lines.Add("TEXT 50,70,\"TSS24.BF2\",0,1,1,\"NOODLES 1 15 15 \" \\r\\n");
UgMemo01.Lines.Add("TEXT 50,100,\"TSS24.BF2\",0,1,1,\"POTATO 1 15 15 \" \\r\\n");
UgMemo01.Lines.Add("TEXT 50,130,\"TSS24.BF2\",0,1,1,\"KNIFE 1 15 15 \" \\r\\n");
UgMemo01.Lines.Add("TEXT 50,160,\"TSS24.BF2\",0,1,1,\"CHICKENS 1 15 15 \" \\r\\n");
UgMemo01.Lines.Add("TEXT 50,175,\"4\",0,1,1,\"--------------------\" \\r\\n");
UgMemo01.Lines.Add("TEXT 50,200,\"TSS24.BF2\",0,1,1,\"SUM 4 60 60 \" \\r\\n");
UgMemo01.Lines.Add("QRCODE 50,230,L,4,A,0,\"isoface.net\" \\r\\n");
UgMemo01.Lines.Add("PRINT 1 \\r\\n");
UgMemo01.Lines.Add("EOP");
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//PasScript
procedure ViewInit;
begin
ugWebSerial01.Visible := False;
UgMemo01.ReadOnly := True;
UgMemo01.Lines.Add('SIZE 40 mm,40 mm \r\n');
UgMemo01.Lines.Add('CLS \r\n');
UgMemo01.Lines.Add('TEXT 50,30,"TSS24.BF2",0,1,1,"Item List" \r\n');
UgMemo01.Lines.Add('TEXT 50,45,"4",0,1,1,"--------------------" \r\n');
UgMemo01.Lines.Add('TEXT 50,70,"TSS24.BF2",0,1,1,"NOODLES 1 15 15 " \r\n');
UgMemo01.Lines.Add('TEXT 50,100,"TSS24.BF2",0,1,1,"POTATO 1 15 15 " \r\n');
UgMemo01.Lines.Add('TEXT 50,130,"TSS24.BF2",0,1,1,"KNIFE 1 15 15 " \r\n');
UgMemo01.Lines.Add('TEXT 50,160,"TSS24.BF2",0,1,1,"CHICKENS 1 15 15 " \r\n');
UgMemo01.Lines.Add('TEXT 50,175,"4",0,1,1,"--------------------" \r\n');
UgMemo01.Lines.Add('TEXT 50,200,"TSS24.BF2",0,1,1,"SUM 4 60 60 " \r\n');
UgMemo01.Lines.Add('QRCODE 50,230,L,4,A,0,"isoface.net" \r\n');
UgMemo01.Lines.Add('PRINT 1 \r\n');
UgMemo01.Lines.Add('EOP');
End;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Make sure to add code blocks to your code group
# 3.2. 事件設定
- 7:UgFSButton01-OnClick事件
點選以開啟通訊埠連線,並預設連線上第一個通訊埠。
//JScript
function UgFSButton01OnClick(sender)
//打開通訊埠
{
ugWebSerial01.Request();
ugWebSerial01.Open(0);
}
2
3
4
5
6
7
8
//PasScript
procedure UgFSButton01OnClick(sender: tobject);
//打開通訊埠
begin
ugWebSerial01.Request();
ugWebSerial01.Open(0);
end;
2
3
4
5
6
7
// Make sure to add code blocks to your code group
- 6:UgFSButton02-OnClick事件
打開寫通訊埠,實現列印。
//JScript
function UgFSButton02OnClick(sender)
//寫通訊埠,實現列印的相關功能
{
ugWebSerial01.WriteLines(s);
}
2
3
4
5
6
//PasScript
procedure UgFSButton02OnClick(sender: tobject);
//寫通訊埠,實現列印的相關功能
begin
ugWebSerial01.WriteLines(s);
end;
2
3
4
5
6
// Make sure to add code blocks to your code group
# 4. 運行結果
使用滑鼠在FastWeb功能表,點選[儲存至資料庫]
按鈕,將其儲存至資料庫,點選[除錯運行]
確認能夠正常打開。
點選 [打開通訊埠]
的按鈕,選擇要連線的設備,並點選連線,之後再點選 [列印]
按鈕,印表機開始執行列印的相關操作。