home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * PROGRAM: Sampproc.prg
- *
- * WRITTEN BY: Borland Samples Group
- *
- * DATE: 6/94
- *
- * UPDATED: 6/94
- *
- * REVISION: $Revision: 1.40 $
- *
- * VERSION: dBASE FOR WINDOWS 5.0
- *
- * DESCRIPTION: This is a general procedure file containing useful functions
- * called by some of the sample programs.
- *
- * PARAMETERS: None
- *
- * CALLS: None
- *
- * USAGE: SET PROCEDURE TO Sampproc.prg
- *
- ********************************************************************************
- #include <Messdlg.h>
-
- InformationMessage("Sampproc.prg is a procedure file used by the samples.","Info")
-
- ********************************************************************************
- function FormatStr(string)
- *
- * Could have 0 or more parameters.
- * This function will replace occurrences of "%<n>" with the corresponding
- * parameter string. It will also replace all occurrences of "\n" with a Carriage
- * Return, and all occurrences of "\t" with a Tab.
- *
- * Example: x = FormatStr("Hello \n %1", "World") &&prints Hello World on 2 lines
- ********************************************************************************
- #define ENTER chr(13)
- #define TAB chr(9)
- local i, strPos, strCnt, tmpStr
-
- tmpStr = string
- for i = 2 to argc() && while have something to search for
- tmpStr = StrTran(tmpStr, "%" + ltrim(str(i - 1)), argv(i))
- next
- tmpStr = StrTran(tmpStr, "\n", ENTER)
- tmpStr = StrTran(tmpStr, "\t", TAB)
-
- return tmpStr
-
-
- *******************************************************************************
- function StrTran(string,curStr,repStr)
- *
- * Replaces all occurrences of curStr in string with repStr
- *******************************************************************************
- local strPos, lenCurStr, tmpStr
- tmpStr = string
- lenCurStr = len(curStr)
- strPos = at(curStr,tmpStr)
- do while strPos > 0
- tmpStr = stuff(tmpStr, strPos, lenCurStr, repStr)
- strPos = at(curStr,tmpStr)
- enddo
- return tmpStr
-
-
-
- *******************************************************************************
- procedure SetEnvironment
- *
- * Environment settings used by most samples
- *******************************************************************************
- set talk off
- set ldCheck off
-
-