HB_DirTemp

HB_DirTemp

Returns name of temp dir of system / user, with closing backslash

Syntax

      HB_DirTemp() -> <SysTempDirName>

Argument

None

Result

<SysTempDirName> : name of temp dir of system / user

Description

HB_DirTemp() is an environment function to obtain name of temp dir of system / user.

This info can be get by SET TEMP command in cmd box and by GETE() function also (see example).

Note that Harbour add a dir-separator (backslash for Windows) to end of <SysTempDirName>.

In Windows, this is : C:\Users\<CurrentUser>\AppData\Local\Temp

Example

      ? HB_DirTemp()
      ? GETE( 'TEMP' )

Seealso

GETE(), GETENV(), HB_GetEnv()

HB_FTempCreate

HB_FTempCreate

Creates and opens a temporary file.

Syntax

      HB_FTempCreate( [<cTempDir>] , ;
                         [<cPrefix>]  , ;
                         [<nFileAttr>], ;
                         [@<cFileName>]  ) --> <nFileHandle>

Arguments

<cTempDir> : An optional character string specifying the directory where to create the temporary file. It defaults to the operating system variable SET TEMP or SET TMP. Operating system variables can be queried with function HB_GetEnv().

<cPrefix> : An optional character string of three characters specifying the prefix to use for the name of the temporary file. It defaults to the string “hb”.

<nFileAttr> : An optional numeric value defining how to create and open the temporary file. See function FCreate() for a description of <nFileAttr>.

@<cFileName> : If specified, <cFileName> must be passed by reference. It receives the file name of the created temporary file as a character string.

Returns

<nFileHandle> : a numeric value > 0 when the temporary file is successfully created. This is the file handle of the created temporary file.

Description

Function HB_FTempCreate() creates a temporary file and opens it. The return value is the file handle of the temporary file. It can be used with low level file functions, such as FWrite() to store data in the file.

Temporary files are often required in an application. HB_FTempCreate() guarantees that the file name of the newly created file is unique, so that no existing file will be overwritten. To obtain the file name of the temporary file, parameter <cFileName> must be passed by reference. It can then later be passed to function FErase() in order to remove the temporary file from disk.

Example

      PROC TestHBFTemp()

         LOCAL nFileHandle
         LOCAL cFileName

         nFileHandle := HB_FTempCreate( ,;   // <cTempDir>
                                        ,;   // <cPrefix>
                                        ,;   // <nFileAttr>
                                        , @cFileName )

         IF nFileHandle > 0
            ? 'Temp file builded with name :', cFileName
            WAIT
            FClose( nFileHandle )
            FErase( cFileName )
         ELSE
            ALERT( "Couldn't build temp file"  )
         ENDI

      RETU // TestHBFTemp()

Seealso

TempFile(), HB_FTempCreateEx(), FCreate(), FErase(), FWrite(), HB_GetEnv()

Harbour All Functions – H

HardCR

HBClass()

HB_ANSITOOEM()

hb_At

hb_cdpSelect

HB_ColorIndex

HB_DiskSpace

HB_EOL

HB_FEof

hb_FLock

hb_FUnlock

hb_gcAll
hb_gcAlloc
hb_gcCollectAll
hb_gcFree
hb_gcItemRef

hb_GetEnv

hb_HAllocate

hb_Hash
hb_HAutoAdd
hb_HBinary
hb_HCaseMatch
hb_HClone
hb_HCopy
hb_HDefault
hb_HDel
hb_HDelAt
hb_HEval
hb_HFill
hb_HGet
hb_HGetDef
hb_HHasKey
hb_HKeyAt
hb_HKeys
hb_HMerge
hb_HPairAt
hb_HPos
hb_HScan
hb_HSet

hb_HSetAutoAdd()
hb_HSetBinary() 
hb_HSetCaseMatch()

hb_HSort
hb_HValueAt
hb_HValues

hb_idleAdd
hb_idleDel
hb_idleState

hb_inetAddress
hb_inetCleanup
hb_inetClearError
hb_inetClearPeriodCallback
hb_inetClearTimeLimit
hb_inetClearTimeout
hb_inetClose
hb_inetConnect
hb_inetConnectIP
hb_inetCount
hb_inetCreate
hb_inetCRLF
hb_inetDataReady
hb_inetDGram
hb_inetDGramBind
hb_inetDGramRecv
hb_inetDGramSend
hb_inetErrorCode
hb_inetErrorDesc
hb_inetFD
hb_inetGetAlias
hb_inetGetHosts
hb_inetGetRcvBufSize
hb_inetGetSndBufSize
hb_inetInit
hb_inetIsSocket
hb_inetPeriodCallback
hb_inetPort
hb_inetRecv
hb_inetRecvAll
hb_inetRecvEndblock
hb_inetRecvLine
hb_inetSend
hb_inetSendAll
hb_inetServer
hb_inetSetRcvBufSize
hb_inetSetSndBufSize
hb_inetstatus
hb_inetTimeLimit
hb_inetTimeout

HB_IsByRef()

hb_keyPut

hb_langErrMsg
hb_langMessage
hb_langName
hb_langSelect

hb_mathErBlock
hb_mathErMode
hb_mathGetErrMode
hb_mathGetHandler
hb_mathGetLastError
hb_mathIsMathErr
hb_mathResetError
hb_mathSetErrMode
hb_mathSetHandler

hb_MemoRead
hb_MemoWrit

hb_RAt

hb_PIsByRef

hb_PValue

hb_SetKeyCheck
hb_SetKeyGet
hb_SetKeySave

hb_setListenerAdd

hb_setListenerNotify
hb_setListenerRemove

hb_SetMacro

hb_Translate

hb_ValToStr

Header

HexaToDec

hb_GetEnv()

HB_GETENV()

Obtains a system environmental setting.

Syntax

      HB_GETENV(<cEnviroment>, [<cDefaultValue>], [<lApplyCodepage>] )
                   --> <cReturn>

Arguments

<cEnviroment> Enviromental variable to obtain.

<cDefaultValue> Optional value to return if <cEnvironment> is not found.

<lApplyCodepage> optional logical parameter specifing whether to apply automatic codepage conversion (to the codepage specified by Set( _SET_OSCODEPAGE ) on the obtained value. The default is .T. Note that if the default value is passed and the environment value is not found, this codepage conversion is not performed against the returned default value

Returns

<cReturn> Value of the environment variable or <cDefaultValue> or an empty string.

Description

This function yields a string that is the value of the environment variable <cEnviroment>, which is stored at the system level.

If no environment variable can be found, the value of the function will be <cDefaultValue> if it is passed, else an empty string.

Examples

      ? HB_GETENV( "PATH" )
      ? HB_GETENV( "CONFIG" )
      ? HB_GETENV( "HARBOURCMD", "-n -l -es2" )

Compliance

Harbour

Platforms

All

Files

src/rtl/gete.c Library is rtl

Seealso

GETENV, GETE