mainapp.bis

来自「用VB实现的编译器的源代码」· BIS 代码 · 共 109 行

BIS
109
字号
//Filename=Start.EXE
debug
include fxVariables.bis
include fxRemoteIO.bis

class AppMain
  
  <definitions>
  
  <methods>
  
  method void run
    > frmMain.show
  end method

end class

class frmMain

  <definitions>

  variable form
    MetaVariable
    [""]
  end variable

  variable txtHost
    Control <controlling ctlTxtHost>
    [""]
  end variable

  variable cmdConnect
    Control <controlling ctlCmdConnect>
    [""]
  end variable

  variable txtStatus
    Control <controlling ctlTxtStatus>
    [""]
  end variable

  <methods>

  method void show
    assignForm fixed ["TCP Socket Test"] [@321] [@240]
    //setFormIcon ["C:\Path\Icon.Ico"]
    addControl TextBox ctlTxtHost
    addControl CommandButton ctlCmdConnect
    addControl TextArea ctlTxtStatus

    set global sckSocket [?N:TCPSocket]

    set this.form [?R:Form]
    set this.txtHost [?R:ctlTxtHost]
    set this.cmdConnect [?R:ctlCmdConnect]
    set this.txtStatus [?R:ctlTxtStatus]

    set this.txtHost.visible [!true]
    set this.txtHost.left [@0]
    set this.txtHost.top [@0]
    set this.txtHost.width [@237]
    set this.txtHost.height [@25]
    set this.txtHost.text ["www.google.com"]
    > this.txtHost.zOrder 1 [@0]

    set this.cmdConnect.visible [!true]
    set this.cmdConnect.left [@232]
    set this.cmdConnect.top [@0]
    set this.cmdConnect.width [@81]
    set this.cmdConnect.height [@25]
    set this.cmdConnect.caption ["Connect"]
    > this.cmdConnect.zOrder 1 [@0]

    set this.txtStatus.visible [!true]
    set this.txtStatus.left [@0]
    set this.txtStatus.top [@32]
    set this.txtStatus.width [@313]
    set this.txtStatus.height [@177]
    set this.txtStatus.text [""]
    > this.txtStatus.zOrder 1 [@0]

    > sckSocket.init
    softThreading on
    schedule 1000 ::
      ThreadHandle ::
      ["set this.form.caption [{String.mid [:this.form.caption] [2]} & {String.left [:this.form.caption] [1]}]"]
    //start ThreadHandle
    windowLoop
  end method

  method void event_Form_Unload
    leave
  end method

  method void event_ctlCmdConnect_Click
    //stop ThreadHandle
    > sckSocket.connect [:this.txtHost.text] [80]
    > sckSocket.writeLn ["GET / HTTP/1.1%0D"]
    set this.txtStatus.text [{sckSocket.read}]
    > sckSocket.close
    //start ThreadHandle
  end method

end class




⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?