-
Notifications
You must be signed in to change notification settings - Fork 1
/
com.src
executable file
·717 lines (611 loc) · 20.7 KB
/
com.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
'##########################################################################
'
' HTTP communication
'
' Set the following parameters:
' - Com.Http.ADDRESS$
' - Com.Http.PORT%
' - Com.Http.URLPREFIX$
' - Com.Http.HOSTNAME$
' by reading CCONFIG.DAT
'
'##########################################################################
'$include:'bhtdef.inc'
'$include:'const.inc'
'$include:'util.inc'
'$include:'screen.def'
'$include:'com.def'
const Com.Status.FtpOpened=4
const Com.Status.FtpDataReceived=5
const Com.Status.FtpClosed=6
'------------------------------------------------------------
' module private variables
'------------------------------------------------------------
private werr
private hCom3%: hCom3% = 2
private interface%
private sockfd%
private ftpHandle%
'------------------------------------------------------------
' open device
'------------------------------------------------------------
function Com.TcpIp.OpenDevice%(status%)
private iftype%
private layermode%
private timeout%
private assoc%
if status% <> Com.Status.Init then
werr=-1
Util.errlog("Com.TcpIp.OpenDevice",werr,status%)
goto opendevice.resume
end if
'-- set tcp/ip
iftype%=2 ' SS wireless device
layermode%=2
call "socket.fn3" .fcTSetup iftype%,layermode%,interface%
on error goto opendevice.err
'-- open device
hCom3%=2
open "COM3:" AS #hCom3%
status%=Com.Status.DeviceOpened
timeout% = 100 '-- 10 sec
call "ss.fn3" .fcSyncInf timeout%, assoc%
if assoc% = -1 then
werr=-1
Util.errlog("Com.TcpIp.OpenDevice",werr,status%)
goto opendevice.resume
endif
Com.TcpIp.OpenDevice%=status%
on error goto 0
exit function
opendevice.err:
werr = err
Util.errlog("Com.TcpIp.OpenDevice",werr,status%)
resume opendevice.resume
opendevice.resume:
on error goto 0
Com.TcpIp.OpenDevice%=Com.Status.Init
end function
'------------------------------------------------------------
' close device
'------------------------------------------------------------
function Com.TcpIp.CloseDevice%(status%)
if status% < Com.Status.DeviceOpened then
werr=-1
Util.errlog("Com.TcpIp.CloseDevice",werr,status%)
goto closedevice.resume
end if
close #hCom3%
closedevice.resume:
Com.TcpIp.CloseDevice%=Com.Status.DeviceClosed
end function
'------------------------------------------------------------
' open TCP/IP
'------------------------------------------------------------
function Com.TcpIp.Open%(status%)
if status% <> Com.Status.DeviceOpened then
werr=-1
Util.errlog("Com.TcpIp.Open",werr,status%)
goto tcpopen.resume
end if
on error goto tcpopen.err
'-- open tcp/ip
call "socket.fn3" .fcTCnnSys interface%
status%=Com.Status.Opened
Com.TcpIp.Open%=status%
on error goto 0
exit function
tcpopen.err:
werr = err
Util.errlog("Com.TcpIp.Open",werr,status%)
resume tcpopen.resume
tcpopen.resume:
on error goto 0
status%=Com.TcpIp.CloseDevice%(status%)
Com.TcpIp.Open%=Com.Status.Init
end function
'------------------------------------------------------------
' close TCP/IP
'------------------------------------------------------------
function Com.TcpIp.Close%(status%)
if status% < Com.Status.Opened then
werr=-1
Util.errlog("Com.TcpIp.Close",werr,status%)
goto tcpclose.resume
end if
call "socket.fn3" .fcTDiscnn interface%
tcpclose.resume:
Com.TcpIp.Close%=Com.Status.Closed
end function
'------------------------------------------------------------
' open socket
'------------------------------------------------------------
function Com.TcpIp.OpenSocket%(status%)
private family%
private type%
private protocol%
private nport%
if status% <> Com.Status.Opened then
werr=-1
Util.errlog("Com.TcpIp.OpenSocket",werr,status%)
goto socketopen.resume
end if
on error goto socketopen.err
'-- create a socket
family%=.soINet
type%=.soStream
protocol%=.soTCP
call "socket.fn3" .fcSocket family%,type%,protocol%,sockfd%
status%=Com.Status.SocketCreated
private option
private optname%
'-- no keep tcp socket
optname%=.soTIMEWAIT
option=0
call "socket.fn3" .fcSSckOpt sockfd%,optname%,option
'-- connect to socket
call "socket.fn3" .fcHToNS Com.Http.PORT%,nport%
call "socket.fn3" .fcConnect sockfd%,family%,nport%,Com.Http.ADDRESS$
status%=Com.Status.SocketConnected
Com.TcpIp.OpenSocket%=status%
on error goto 0
exit function
socketopen.err:
werr = err
Util.errlog("Com.TcpIp.OpenSocket",werr,status%)
resume socketopen.resume
socketopen.resume:
on error goto 0
Com.TcpIp.OpenSocket%=Com.TcpIp.Close%(status%)
if (werr<>&h105) and (werr<>&h450) then
Com.TcpIp.OpenSocket%=Com.Status.DeviceOpened
end if
end function
'------------------------------------------------------------
' close socket
'------------------------------------------------------------
function Com.TcpIp.CloseSocket%(status%)
if status% < Com.Status.SocketConnected then
werr=-1
Util.errlog("Com.TcpIp.CloseSocket",werr,status%)
goto socketclose.resume
end if
call "socket.fn3" .fcClose sockfd%
socketclose.resume:
Com.TcpIp.CloseSocket%=Com.Status.SocketClosed
end function
'------------------------------------------------------------
' send data
'------------------------------------------------------------
function Com.Http.SendData%(mode%,req$,param$,status%)
private sendlen%
private sendmode%
private sendsize%
if status% <>Com.Status.SocketConnected then
werr=-1
Util.errlog("Com.Http.SendData",werr,status%)
goto senddata.resume
end if
on error goto senddata.err
'-- send data
if mode%=Com.Http.GetMode then
'-- GET
Com.Http.Sendbuff$="GET "+req$+" HTTP/1.0"+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+"Host: "+Com.Http.HOSTNAME$+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+"User-Agent: BHT300BW"+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+Com.Http.EOLEOL$
else
'-- POST
Com.Http.Sendbuff$="POST "+req$+" HTTP/1.0"+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+"Host: "+Com.Http.HOSTNAME$+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+"User-Agent: BHT300BW"+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+"Content-Type: application/x-www-form-urlencoded"+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+"Content-Length:"+str$(len(param$))+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+Com.Http.EOL$
Com.Http.Sendbuff$=Com.Http.Sendbuff$+param$+Com.Http.EOLEOL$
end if
sendlen%=len(Com.Http.Sendbuff$)
sendmode%=.soSdNrm
call "socket.fn3" .fcSend sockfd%,Com.Http.Sendbuff$,sendlen%,sendmode%,sendsize%
status%=Com.Status.DataSent
Com.Http.SendData%=status%
on error goto 0
exit function
senddata.err:
werr = err
Util.errlog("Com.Http.SendData",werr,status%)
resume senddata.resume
senddata.resume:
on error goto 0
Com.Http.SendData%=Com.TcpIp.CloseSocket%(status%)
if (werr <> &h105) and (werr<>&h106) and (werr<>&h108) and (werr<>&h450) then
Com.Http.SendData%=Com.Status.Opened
end if
end function
'------------------------------------------------------------
' receive data
'------------------------------------------------------------
function Com.Http.RecvData%(byref ret$,status%)
private recvlen%
private recvmode%
private recvsize%
private recvflag%
if status% <> Com.Status.DataSent then
werr=-1
Util.errlog("Com.Http.RecvData",werr,status%)
goto recvdata.resume
end if
on error goto recvdata.err
'-- receive data
recvlen%=Com.RECVSIZE
recvmode%=.soRvNrm
recvflag%=.soRvWrite
call "socket.fn3" .fcRecv sockfd%,Com.Http.Recvbuff$,recvlen%,recvmode%,recvsize%,recvflag%
status%=Com.Status.DataReceived
private ret%
ret%=val(mid$(Com.Http.Recvbuff$,10,3)) 'HTTP code
if ret%<>200 then
ret$="ERR=>HTTP,Code:"+str$(ret%)
goto recvdata.resume
end if
'-- get content length
private pos%
pos%=instr(16,Com.Http.Recvbuff$,Com.Http.LENGTH$)
if pos%=0 then
ret$="ERR=>HTTP,Data:no length"
goto recvdata.resume
end if
pos%=pos%+len(Com.Http.LENGTH$)
private pos2%
pos2%=instr(pos%,Com.Http.Recvbuff$,Com.Http.EOL$)
if pos2%=0 then
ret$="ERR=>HTTP,Data:no data"
goto recvdata.resume
end if
private clen%
clen%=val(mid$(Com.Http.Recvbuff$,pos%,pos2%-pos%))
'-- move pointer to body
pos2%=instr(pos2%-1,Com.Http.Recvbuff$,Com.Http.EOLEOL$)
if pos2%=0 then
ret$="ERR=>HTTP,Data:no data"
goto recvdata.resume
end if
ret$=mid$(Com.Http.Recvbuff$,pos2%+len(Com.Http.EOLEOL$),clen%)
Com.Http.RecvData%=status%
on error goto 0
exit function
recvdata.err:
werr = err
Util.errlog("Com.Http.RecvData",werr,status%)
resume recvdata.resume
recvdata.resume:
on error goto 0
Com.Http.RecvData%=Com.TcpIp.CloseSocket%(status%)
if (werr <> &h105) and (werr<>&h106) and (werr<>&h108) and (werr<>&h450) then
Com.Http.RecvData%=Com.Status.Opened
end if
end function
'------------------------------------------------------------
' open FTP
'------------------------------------------------------------
function Com.Ftp.Open%(status%)
private reply%
if status% <>Com.Status.Opened then
werr=-1
Util.errlog("Com.Ftp.Open",werr,status%)
goto ftpopen.resume
end if
on error goto ftpopen.err
'-- open
call "ftp.fn3" .fcFTPOpnS ftpHandle%,reply%
'-- call "ftp.fn3" .fcFTPOpnU ftpHandle%,APP.SERV.IP$,APP.USER$,APP.PASS$,reply%
'-- get system directory
private para%
private newDir$[65]
para% = .ftDefDir
call "ftp.fn3" .fcFSysGet para%,newDir$
'-- set current directory
call "ftp.fn3" .fcCWD ftpHandle%, newDir$,reply%
status%=Com.Status.FtpOpened
print newDir$;
print "/"
Com.Ftp.Open%=status%
on error goto 0
exit function
ftpopen.err:
werr = err
Util.errlog("Com.Ftp.Open",werr,status%)
resume ftpopen.resume
ftpopen.resume:
on error goto 0
Com.Ftp.Open%=Com.TcpIp.Close%(status%)
if (werr<>&h105) and (werr<>&h450) then
Com.Ftp.Open%=Com.Status.DeviceOpened
end if
end function
'------------------------------------------------------------
' close FTP
'------------------------------------------------------------
function Com.Ftp.Close%(status%)
if status% < Com.Status.FtpOpened then
werr=-1
Util.errlog("Com.Ftp.Close",werr,status%)
goto ftpclose.resume
end if
private reply%
call "ftp.fn3" .fcFTPClos ftpHandle%,reply%
ftpclose.resume:
Com.Ftp.Close%=Com.Status.FtpClosed
end function
'------------------------------------------------------------
' receive file(s)
'------------------------------------------------------------
function Com.Ftp.RecvFile%(req$,param$,byref files$(),size%,status%)
private reply%
private clntFname$: clntFname$=""
private crlf.type%: crlf.type%=.ftCRLF
private crlf.mode%: crlf.mode%=.ftRcdSepa
private disp.mode%: disp.mode%=.ftDisp
if status% <> Com.Status.FtpOpened then
werr=-1
Util.errlog("Com.Ftp.RecvFile",werr,status%)
goto recvfile.resume
end if
on error goto recvfile.err
if param$="" then
' -- PD4 files
private i%
private servFname$[20]
for i%=0 to (size%-1)
servFname$=files$(i%)
print " ";
print servFname$
call "ftp.fn3" .fcRETR ftpHandle%,servFname$,clntFname$,crlf.type%,crlf.mode%,reply%,disp.mode%
next
else
' -- data file
call "ftp.fn3" .fcRETR ftpHandle%,req$,clntFname$,crlf.type%,crlf.mode%,reply%,param$,disp.mode%
end if
status%=Com.Status.FtpDataReceived
Com.Ftp.RecvFile%=status%
on error goto 0
exit function
recvfile.err:
werr = err
Util.errlog("Com.Ftp.RecvFile",werr,status%)
resume recvfile.resume
recvfile.resume:
on error goto 0
Com.Ftp.RecvFile%=Com.Ftp.Close%(status%)
end function
'--------------------------------------------------------------------------
' get php name
'--------------------------------------------------------------------------
function Com.GetPhpName$(req$)
private phplen%
phplen%=instr(len(Com.Http.URLPREFIX$)+2,req$,".")-len(Com.Http.URLPREFIX$)-2
Com.GetPhpName$=mid$(req$,len(Com.Http.URLPREFIX$)+2,phplen%)
end function
'------------------------------------------------------------
' HTTP Request
'------------------------------------------------------------
function Com.Http.Request$(mode%,req$,param$)[Com.RECVSIZE]
private startTime$[8]
private endTime$[8]
startTime$ = time$ '-- start measuring
private ret$[Com.RECVSIZE]
private status%
status%=Com.Status.Init '-- init status
'-- state machine
while status%<>Com.Status.DeviceClosed
werr=0 '-- reset error
select status%
case Com.Status.Init
status%=Com.TcpIp.OpenDevice%(status%)
case Com.Status.DeviceOpened
status%=Com.TcpIp.Open%(status%)
case Com.Status.Opened
status%=Com.TcpIp.OpenSocket%(status%)
case Com.Status.SocketConnected
status%=Com.Http.SendData%(mode%,req$,param$,status%)
case Com.Status.DataSent
status%=Com.Http.RecvData%(ret$,status%)
case Com.Status.DataReceived
status%=Com.TcpIp.CloseSocket%(status%)
case Com.Status.SocketClosed
status%=Com.TcpIp.Close%(status%)
case Com.Status.Closed
status%=Com.TcpIp.CloseDevice%(status%)
end select
wend
Com.Http.Request$ = ret$
endTime$=time$
APP.ELAPSEDTIME% = Util.GetSeconds%(startTime$, endTime$)
APP.DEBUGMSG$ = Com.GetPhpName$(req$)
end function
'------------------------------------------------------------
' HTTP Get
'------------------------------------------------------------
function Com.Http.Get$(req$)[Com.RECVSIZE]
Com.Http.Get$=Com.Http.Request$(Com.Http.GetMode,req$,"")
end function
'------------------------------------------------------------
' HTTP Post
'------------------------------------------------------------
function Com.Http.Post$(req$,param$)[Com.RECVSIZE]
Com.Http.Post$=Com.Http.Request$(Com.Http.PostMode,req$,param$)
end function
'------------------------------------------------------------
' FTP Download Program
'------------------------------------------------------------
function Com.Ftp.DownloadProgram$(byref files$(),size%)[1]
private status%
status%=Com.Status.Init '-- init status
while status%<>Com.Status.DeviceClosed
werr=0 '-- reset error
select status%
case Com.Status.Init
status%=Com.TcpIp.OpenDevice%(status%)
case Com.Status.DeviceOpened
status%=Com.TcpIp.Open%(status%)
case Com.Status.Opened
status%=Com.Ftp.Open%(status%)
case Com.Status.FtpOpened
status%=Com.Ftp.RecvFile%("","",files$,size%,status%)
case Com.Status.FtpDataReceived
status%=Com.Ftp.Close%(status%)
case Com.Status.FtpClosed
status%=Com.TcpIp.Close%(status%)
case Com.Status.Closed
status%=Com.TcpIp.CloseDevice%(status%)
end select
wend
Com.Ftp.DownloadProgram$=""
end function
'------------------------------------------------------------
' FTP Download Data
'------------------------------------------------------------
function Com.Ftp.DownloadData$(req$,param$)[1]
private status%
status%=Com.Status.Init '-- init status
while status%<>Com.Status.DeviceClosed
werr=0 '-- reset error
select status%
case Com.Status.Init
status%=Com.TcpIp.OpenDevice%(status%)
case Com.Status.DeviceOpened
status%=Com.TcpIp.Open%(status%)
case Com.Status.Opened
status%=Com.Ftp.Open%(status%)
case Com.Status.FtpOpened
status%=Com.Ftp.RecvFile%(req$,param$,Com.EmptyFiles$,0,status%)
case Com.Status.FtpDataReceived
status%=Com.Ftp.Close%(status%)
case Com.Status.FtpClosed
status%=Com.TcpIp.Close%(status%)
case Com.Status.Closed
status%=Com.TcpIp.CloseDevice%(status%)
end select
wend
Com.Ftp.DownloadData$=""
end function
'--------------------------------------------------------------------------
' read config
'--------------------------------------------------------------------------
sub Com.ReadConfig
private fileNum%:fileNum% = 4
private flen%
private i%
private key$[16]
private value$[64]
open Com.ConfigFileName$ AS #fileNum%
field #fileNum%, 16 as key$, 64 as value$
flen%=lof(#fileNum%)
for i%=1 to flen%
get #fileNum%,i%
key$=Util.Trim$(key$)
value$=Util.Trim$(value$)
select key$
case "http.path"
Com.Http.URLPREFIX$=value$
case "http.address"
Com.Http.ADDRESS$=value$
case "http.port"
Com.Http.PORT%=val(value$)
case "http.hostname"
Com.Http.HOSTNAME$=value$
end select
next
close #fileNum%
private r$[1]
if Com.Http.URLPREFIX$="" then
print "パスが設定されてません";
input r$
else
print "パス:["+Com.Http.URLPREFIX$+"]"
end if
if Com.Http.ADDRESS$="" then
print "HTTPアドレスが設定されてません";
input r$
else
print "HTTPアドレス:["+Com.Http.ADDRESS$+"]"
end if
if Com.Http.PORT%=0 then
print "HTTPポートが設定されてません";
input r$
else
print "HTTPポート:["+str$(Com.Http.PORT%)+"]"
'--input r$
end if
end sub
'--------------------------------------------------------------------------
' print wireless parameters
'--------------------------------------------------------------------------
sub Com.PrintWirelessParam
private para%
private data$[32]
print "WIRELESS=>";
para%=1
call "ss.fn3" .fcParaDSGet para%,data$
print data$;
para%=2
call "ss.fn3" .fcParaDSGet para%,data$
print ","+data$;
para%=3
call "ss.fn3" .fcParaDSGet para%,data$
print ","+data$;
end sub
'--------------------------------------------------------------------------
' print tcp parameters
'--------------------------------------------------------------------------
sub Com.PrintTcpParam
private para%
private dataS$[15]
private data%
print "TCP=>";
para%=.soDvGet
call "socket.fn3" .fcTSysGet para%,data%
print str$(data%);
para%=.soLyGet
call "socket.fn3" .fcTSysGet para%,data%
print ","+str$(data%);
para%=.soPmIPAdr
call "socket.fn3" .fcTSysGet para%,dataS$
print ","+dataS$
para%=.soPmNtMsk
call "socket.fn3" .fcTSysGet para%,dataS$
print ","+dataS$
para%=.soPmDGWay
call "socket.fn3" .fcTSysGet para%,dataS$
print ","+dataS$
end sub
'--------------------------------------------------------------------------
' print socket parameters
'--------------------------------------------------------------------------
sub Com.PrintSocketParam(sfd%)
private optname%
private option
private buf$
print "SOCKFD => "+str$(sfd%);
optname%=.soSndBuff
call "socket.fn3" .fcGSckOpt sfd%,optname%,option
print ":BUFF="+hex$(option)
optname%=.soRcvBuff
call "socket.fn3" .fcGSckOpt sfd%,optname%,option
print ","+str$(option);
optname%=.soMaxRT
call "socket.fn3" .fcGSckOpt sfd%,optname%,option
print ",RETRY="+str$(option);
optname%=.soTIMEWAIT
call "socket.fn3" .fcGSckOpt sfd%,optname%,option
print ",TIMEWAIT="+str$(option);
optname%=.soRTODef
call "socket.fn3" .fcGSckOpt sfd%,optname%,option
print ",RTODef="+str$(option);
optname%=.soRTOMin
call "socket.fn3" .fcGSckOpt sfd%,optname%,option
print ",RTOMin="+str$(option);
optname%=.soRTOMax
call "socket.fn3" .fcGSckOpt sfd%,optname%,option
print ",RTOMax="+str$(option)
end sub