Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - getscrchar() return the character at screen location http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 getscrchar()        Return the character at screen location
------------------------------------------------------------------------------
 Declaration
   screen.hdr

 Syntax
   func uint getscrchar extern
   param value uint uRow, ;
         value uint uCol

 Arguments
   uRow is a screen row number.
   uCol is a screen column number.

 Return
   An ASCII character code.

 Description
   This function returns the current screen character at the specified
   screen position. The function performs a direct access to the screen
   memory, independent of the current screen driver.

 Example
   #define EXAMPLE_SCREEN
   #include example.hdr

   // Write the text from the screen to a file
   
   proc ScreenText
   param value uint nTop, ;
         value uint nLeft, ;
         value uint nBottom, ;
         value uint nRight, ;
         value ptr( byte ) pBuffer
   vardef
     uint nRow
     uint nCol
     uint i
   enddef
   i := 0
   for nRow := nTop to nBottom
      for nCol := nLeft to nRight
         *pBuffer := getscrchar( nRow, nCol ) // get character from screen
         pBuffer++
      next
      *pBuffer := 13                          // add line end
      pBuffer++
      *pBuffer := 10
      pBuffer++
   next
   *pBuffer := 0                              // close buffer
   endproc
   
   proc Test_getscrchar
   vardef
      ptr( byte ) pBuffer, pTemp
      file        fTemp
   enddef
   pBuffer := malloc( 6000 )                  // allocate buffer
   if pBuffer
      ScreenText( 0, 0, __max_row, __max_col, pBuffer ) // fill buffer
      fopen( fTemp, "test.txt", F_CREATE, F_TEXT )      // open file
      pTemp := pBuffer
      do while *pTemp > 0
         fputc( fTemp, *pTemp )                         // write to file
         pTemp++
      enddo
      free( pBuffer )
      fclose( fTemp )                         // close file
      type "test.txt"                         // display file
      erase "test.txt"                        // clean up
   endif
   endproc

   proc main
   Test_getscrchar()
   endproc

See Also: getscrattr() getscrcharattr() putscrchar()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson