home *** CD-ROM | disk | FTP | other *** search
- // UDFLIB.PRG
- // Employee Information general library functions
- // November, 1993
-
- #include "sys.ch"
-
- FUNCTION CenterIt(TheData, TheWidth)
- LOCAL ThePad
-
- ThePad := (TheWidth - Len(TheData)) / 2
-
- RETURN Space(Int(ThePad)) + TheData + Space(ThePad + .5)
-
-
- FUNCTION ErrorMsg(TheMsg)
- LOCAL OldCursor, OldColor, TheWidth, TheLeft, TheRight, OldWindow
-
- OldCursor := SetCursor(SC_NONE)
- OldColor := Error_Color()
- TheWidth := Max(Len(TheMsg), 23)
- TheLeft := Int((80 - TheWidth) / 2 - 2)
- TheRight := TheLeft + TheWidth + 4
-
- OldWindow := Win_Open(8, TheLeft, 14, TheRight, ' Error ')
-
- @ 9, TheLeft + 1 CLEAR TO 13, TheRight - 1
- @ 10, TheLeft + 2 SAY CenterIt(TheMsg, TheWidth)
- @ 12, TheLeft + 2 SAY CenterIt('Press Esc to continue', TheWidth)
-
- DO WHILE !InKey(0) = K_ESC
- ENDDO
-
- Win_Close(OldWindow)
- SetColor(OldColor)
- SetCursor(OldCursor)
-
- RETURN FALSE
-
-
- FUNCTION Confirm(TheRow, TheColumn, TheAction, TheMsg, TheMode)
- LOCAL TheChoice, OldCursor, OldColor, OldRow, OldCol, OldWindow, OldMsg
-
- IF !ISLOGICAL(TheMode)
- TheChoice := 1
-
- ELSEIF TheMode
- TheChoice := 1
-
- ELSE
- TheChoice := 2
-
- ENDIF
-
- OldCursor := SetCursor(SC_NONE)
- OldColor := Warning_Color()
- OldRow := Row()
- OldCol := Col()
-
- OldWindow := Win_Open(TheRow, TheColumn, TheRow + 6, TheColumn + 20, ' ' + TheAction + ': ')
- @ TheRow + 2, TheColumn + 4 SAY 'Are you sure?'
- OldMsg := Msg(TheMsg)
-
- @ TheRow + 4, TheColumn + 3 PROMPT ' Yes '
- @ TheRow + 4, TheColumn + 14 PROMPT ' No '
- MENU TO TheChoice
-
- Win_Close(OldWindow)
- Msg(OldMsg)
- SetColor(OldColor)
- SetCursor(OldCursor)
- DevPos(OldRow, OldCol)
-
- RETURN TheChoice = 1
-
-
- FUNCTION Macro(TheMacro)
-
- RETURN &TheMacro
-
-
- FUNCTION Get_Path(TheVar)
- LOCAL ThePath
-
- ThePath := GetEnv(Upper(TheVar))
-
- IF Empty(ThePath)
- ThePath := 'C:\CAVO\SAMPLES\EMPLOYEE\'
-
- ELSEIF !Right(ThePath, 1) == '\'
- ThePath += '\'
-
- ENDIF
-
- RETURN ThePath
-
-
- FUNCTION Sys_Init()
-
- Set(_SET_DELETED, TRUE)
- Set(_SET_SCOREBOARD, FALSE)
- SetCursor(SC_NONE)
-
- RETURN TRUE
-
-
- FUNCTION Build_Msg(TheModule, TheMsg, TheMode)
- LOCAL ThePre, ThePost
-
- IF TheMode = ENTRY_MODE
- ThePre := 'Enter'
- ThePost := ' - Esc to abort'
-
- ELSEIF TheMode = UPDATE_MODE
- ThePre := 'Change'
- ThePost := ' - Enter to accept'
-
- ELSEIF TheMode = POSITION_MODE
- ThePre := 'Enter'
- ThePost := ' - OR - leave blank to browse'
-
- ENDIF
-
- RETURN ThePre + ;
- ' the ' + ;
- TheModule + ;
- ' ' + ;
- TheMsg + ;
- ThePost
-
-
- FUNCTION Msg(TheMsg)
- LOCAL OldMsg, OldColor, OldRow, OldCol
-
- OldMsg := OddBytes(SaveScreen(24, 0, 24, 79))
-
- IF !ISUNDEFINED(TheMsg)
- OldColor := Message_Color()
- OldRow := Row()
- OldCol := Col()
-
- @ 24, 0 SAY CenterIt(TheMsg, 80)
-
- SetColor(OldColor)
- DevPos(OldRow, OldCol)
- ENDIF
-
- RETURN OldMsg
-
-
- FUNCTION OddBytes(TheString)
- LOCAL TheReturn, TheCount, TheTotal
-
- TheReturn := ""
- TheTotal := Len(TheString)
-
- FOR TheCount := 1 TO TheTotal STEP 2
- TheReturn += SubStr(TheString, TheCount, 1)
- NEXT
-
- RETURN TheReturn
-
-
- FUNCTION FullString(TheString, Strictly)
-
- IF !ISLOGICAL(Strictly)
- ELSEIF !Strictly
- TheString := AllTrim(TheString)
- ENDIF
-
- RETURN !SUBSET(' ', TheString)
-
-
- FUNCTION RZero(TheString)
- LOCAL TheLength
-
- TheLength := Len(TheString)
- TheString := LTrim(TheString)
-
- RETURN Replicate('0', TheLength - Len(TheString)) + TheString
-
- FUNCTION Read_It(GetList)
- LOCAL OldCursor
-
- OldCursor := SetCursor(SC_NORMAL)
- READ
- SetCursor(OldCursor)
-
- RETURN LastKey()
-
-