BASIC "Hello World"

Also for BASIC:
An example in powerbasic


#COMPILE EXE

#INCLUDE "FCGX_Header.inc"
   

'//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤'
FUNCTION WINMAIN()

  LOCAL sReply AS STRING 
  LOCAL FCGXReq AS FCGX_REQUEST  '// FCGX Structure

'// Intialize Databases etc here     

    '// Create the STDIN/STDOUT/STDERR buffers, Connect with the Web Server via FCGI Library
    CALL FCGX_InitRequest(VARPTR(FCGXReq) , 0, 0)


    DO '// Main Request processing loop

      '// Execution blocked here until an HTTP request arrives
      IF FCGX_Accept_r(VARPTR(FCGXReq) ) < 0 THEN EXIT LOOP '// SIGTERM/Error recieved - jump out and cleanup


      '// The reply must begin with a valid HTTP header
      sReply = "Content-Type: text/html"+$CRLF+$CRLF             
      sReply = sReply + "Hello World, Count=" + STR$(FCGXReq.ReqCount)

      '// Add the Reply string to the STDOUT buffer
      IF FCGX_PutStr( STRPTR(sReply), LEN(sReply), FCGXReq.pOut ) < 0 THEN EXIT LOOP '// Error Occured

    LOOP '// STDOUT is sent when FCGX_Accept_r is called again

'// Close Databases etc here

END FUNCTION

'//¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤'
Comments