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 - __c_dot string constant (dot character) http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 __c_dot             String constant (dot character)
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   char(1) __c_dot

 Default
   "."

 Description
   The __c_dot system constant contains the dot character as a string.

   System-defined string constants can be used to save data segment
   space by avoiding the redundant declaration of certain frequently used
   string constants in application code.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   // This function returns the extension of a file name
   
   func char( 3 ) FindExtension
   param const char cFile
   vardef
      uint      nPos
      char( 3 ) cExt
   enddef
   nPos := rat( __c_dot, cFile )          // determine position of rightmost dot
   if nPos > 0                            // if dot found
      if substr( cFile, nPos + 1, 1 ) == __c_dot .or. ; // if dot does not...
         substr( cFile, nPos + 1, 1 ) == __c_backslash  // belong to extension
         nPos := 0                                      // reset dot position
      else                                // if dot belongs to extension
         cExt := substr( cFile, nPos + 1, 3 ) // copy to return string
      endif
   endif
   if nPos == 0                           // if there is no extension
      cExt := __c_empty                   // reset return string
   endif
   return( cExt )                         // return extension
   endfunc
   
   proc Test_c_dot
   vardef
      char      cFileName
      char( 3 ) cExt
   enddef
   ? FindExtension( "test.prg" )          // print "prg"
   ? FindExtension( "test" )              // print ""
   ? FindExtension( ".\test.txt" )        // print "txt"
   ? FindExtension( "..\test" )           // print ""
   ? FindExtension( "..\test.bak" )       // print "bak"
   endproc

   proc main
   Test_c_dot()
   endproc

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