home *** CD-ROM | disk | FTP | other *** search
- /* REPT23A.PRG
-
- Convert @ SAY printing statements to output to .TXT file under FiveWin,
- which will be printed later using Seiler's REPT23.PRG (formerly Rep23.prg -
- name changed to avoid getting stepped on by future sample reports from
- Ignacio Ortiz)
-
- Written by Roger Seiler 12/23/95
-
- Compile: Clipper Rept23a /n /m /w
- Link: Blinker fi Rept23a @FiveWin
- */
- #include "Fivewin.ch"
-
- STATIC nRow := 0, nRowB := 0, cNewLine := "", cText := ""
-
- PROCEDURE REPT23A()
-
- LOCAL cMemvar := "" // default dummy memvar in case quoted text used in @ SAY
- LOCAL cMyMemvar := "And so does this." // an actual memvar
- LOCAL cTxtFile := " .TXT"
- LOCAL lGoAhead := .f.
- lGoAhead := MsgGet("Print To Text File","Enter name of text file:",@cTxtFile)
-
- *-------
- /* Original DOS @ SAY printing specs:
-
- @ 3, 5 SAY "This goes to printer text file."
- @ 3,38 SAY cMyMemvar
- @ 5, 5 SAY "And also this."
-
- // For FiveWin, to print to text file, add to beginning and end of each line,
- // use function ToTxt('at-say', cMemvar) or in other words:
-
- ToTxt(' *** @ SAY statement *** followed by: ', cMemvar)
- ^^^^^^^ ^^^^^^^^^^^
- // note use of single quotes at beginning and end of the 1st ToText param:
- */
- // @ SAYs modified for FiveWin:
-
- ToTxt('@ 3, 5 SAY "This goes to printer text file."', cMemvar)
- ToTxt('@ 3,38 SAY cMyMemvar', cMyMemvar)
- ToTxt('@ 5, 5 SAY "And also this."', cMemvar)
-
- *--------
-
- // At end of job, we add the last line to cText and tack on a carriage return:
- cText := cText + cNewLine+CRLF
-
- // Then we write it to disk as a .TXT file:
- MEMOWRIT(cTxtfile, cText)
-
-
- RETURN
- *------------------------------- End Proc TestPrnt()
-
- FUNCTION ToTxt(cLine,cMemvar)
-
- // This function analyzes each @ SAY statement in order to position each piece
- // of text correctly on the page, building the text one line at a time, and
- // then adds each line to a string that will be written to a text file.
-
- LOCAL nAt1,nAt2,nAt3,nCol,cBlanks
- LOCAL nBlanks := 0
-
- nRowB := 0
-
- // Find row number:
- nAt1 := AT("@", cLine)
- nAt2 := AT(",", cLine)
- nRowB := VAL( SUBSTR(cLine,nAt1+1,(nAt2-1-nAt1)) )
-
- // Just at beginning of first pass:
- IF nRow = 0
- DO WHILE nRow # nRowB
- nRow := nRow + 1
- IF nRowB > nRow
- cText := cText + CRLF
- ENDIF
- ENDDO
- ENDIF
-
- // Find column number:
- nAt3 := AT("SAY", cLine)
- IF nAt3 = 0 // Try again if not found above - maybe upper & lower case:
- nAt3 := AT("Say", cLine)
- ENDIF
- IF nAt3 = 0 // If still not found, maybe all lower case:
- nAt3 := AT("say", cLine)
- ENDIF
- IF nAt3 = 0
- MsgAlert('Error in finding "SAY" in line ' + STR(nRowB) )
- RETURN nil
- ENDIF
-
- nCol := VAL( SUBSTR(cLine,nAt2+1,(nAt3-1-nAt2)) )
-
- // If moving to a new row, then add the line just finished to cText memvar,
- // and tack on a carriage return at end of the line:
- IF nRowB > nRow .AND. nRow > 0
- cText := cText + cNewLine+CRLF
- // Initialize a new line:
- cNewLine := ""
- // If next line to be printed is more than one line down the page,
- // then add appropriate # of carriage returns to get to it:
- DO WHILE nRow # nRowB
- nRow := nRow + 1
- IF nRowB > nRow
- cText := cText + CRLF
- ENDIF
- ENDDO
- ENDIF
-
- // If we need to space over to where next piece of text is to be added to a
- // line, then determine # of blank spaces needed and add them onto the line:
- nBlanks := (nCol - 1) - LEN(cNewLine)
- cBlanks := SPACE(nBlanks)
- IF nBlanks > 0
- cNewLine := cNewLine + cBlanks
- ENDIF
- // If this piece of text to be added was passed here in cMemvar, then add it
- // to the line:
- IF !EMPTY(cMemvar)
- cNewLine := cNewLine + cMemvar
- ELSE // If text piece to be added is in a quote instead of cMemvar:
- cNewLine := cNewLine + SUBSTR(cLine, nAt3 + 5, LEN(cLine)-(nAt3+5))
- ENDIF
-
- RETURN nil
-
- *----------------------------- End ToText()
-