Language VFP (Visual FoxPro)
(Using Textmerge and access methods)
Date: | 04/12/08 |
Author: | Daniel B. Johnson |
URL: | n/a |
Comments: | 0 |
Info: | http://msdn2.microsoft.com/en-us/vfoxpro/default.aspx |
Score: | (3.00 in 6 votes) |
* ===================================================================== * * Program: Beer class * * ===================================================================== * * Purpose: List the complete lyrics to the song 99 bottles of Beer, * * and create a txt file of same. * * * * Created: 04/11/2008 10:47 AM * * Author: Daniel B. Johnson * * * * ===================================================================== * * To execute, start Visual FoxPro, execut at command prompt. * * ===================================================================== * oSong = CREATEOBJECT("BeerSong") oSong.sing() oSong = .NULL. * ===================================================================== * DEFINE CLASS BeerSong AS Session OLEPUBLIC * ===================================================================== * PROTECTED nBeer AS Number PROTECTED cBeer, ; cNextBeer as Character PROCEDURE sing as Logical ************************* SET TEXTMERGE TO beer.txt SET TEXTMERGE ON SHOW WITH THIS FOR .nBeer = 99 TO 0 STEP -1 \<<.cBeer>> bottle<<.cPlural(.nBeer)>> of beer on the wall, \\ <<LOWER(.cBeer)>> bottle<<.cPlural(.nBeer)>> of beer. IF .nBeer <> 0 \Take one down and pass it around, ELSE \Go to the store and buy some more, ENDIF \\ <<.cNextBeer>> bottle<<.cPlural(.nBeer-1)>> of beer on the wall. \ ENDFOR ENDWITH SET TEXTMERGE OFF SET TEXTMERGE TO RETURN .T. ENDPROC PROCEDURE cBeer_access ********************** RETURN IIF(.nBeer <> 0, ALLTRIM(PADR(.nBeer,2)), "No more") ENDPROC PROCEDURE cNextBeer_access ************************** DO CASE CASE .nBeer > 1 RETURN ALLTRIM(PADR(.nBeer - 1,2)) CASE .nBeer = 1 RETURN "no more" CASE .nBeer = 0 RETURN "99" ENDCASE ENDPROC PROTECTED PROCEDURE cPlural *************************** LPARAMETERS vnBottles RETURN IIF(vnBottles <> 1,'s','') ENDPROC * ===================================================================== * ENDDEFINE * ===================================================================== *
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments