home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / wordwrap.zip / WRAP.PRG < prev   
Text File  |  1987-01-27  |  2KB  |  60 lines

  1. * Program ...: Wraptest.PRG
  2. * Author ....: Kenneth N. Getz
  3. * Date ......: 21 September 1986
  4. *                                    Modified: 7 October 1986
  5. * Version ...: dBASE III PLUS, (Developer's Release)
  6. * Note(s) ...: This is a program to used to demonstrate Wrap.BIN, an assembly language module that 
  7. *                          takes in a wrap length, a buffer area, and a string to be wrapped.  It passes back 
  8. *                           the string truncated to the wraplength with the extra text in the buffer area.
  9. *
  10. USE Wraptest
  11. SET TALK OFF
  12. LOAD WRAP                                    && Binary procedure that controls wrapping.
  13. SET PROCEDURE TO Empty        && Clears out buffer before going to next record.
  14. *
  15. * Get wrap width and offset from the left from the user, checking to make sure that the width plus
  16. * the offset is less than the output width.  If not, the offset is adjusted to make sure all columns 
  17. * fit on the output.
  18. *
  19. STORE 80 TO OutWidth
  20. STORE 0 TO WidthNum
  21. STORE 0 TO Offset
  22. CLEAR
  23. INPUT 'Wrap to how many columns: ' TO WidthNum
  24. INPUT 'To what Offset: ' TO Offset
  25. Offset = IIF( WidthNum + Offset > OutWidth, OutWidth-WidthNum, Offset )
  26. CLEAR
  27. *
  28. * Now initialize the important variables.  All programs using Wrap.BIN must initialize three variables
  29. * just like these.  Though the names are unimportant, the sizes and the order are VERY important.  They 
  30. * must also be declared consecutively for the program to work.
  31. *
  32. STORE CHR(WidthNum) TO Width
  33. STORE SPACE(254) TO Buffer
  34. STORE SPACE(254) TO WrapString
  35. **
  36. ** If the buffer is empty, copy the next record to the WrapString.
  37. ** If not, copy trimmed Buffer, a space, and the trimmed record to WrapString.
  38. **
  39. DO WHILE .NOT. EOF()
  40.     IF LEN(TRIM(Line)) = 0
  41.         DO Empty WITH 0
  42.         ? 
  43.         SKIP
  44.         LOOP
  45.     ENDIF
  46.   STORE IIF(LEN(TRIM(Buffer))<>0,TRIM(Buffer) + ' ' + TRIM(LINE),TRIM(LINE)) TO WrapString
  47.   CALL WRAP WITH WrapString
  48.   ? SPACE(Offset) + WrapString
  49.     DO Empty WITH Widthnum
  50.     SKIP
  51. ENDDO
  52. **
  53. ** Now that we're at the end of the file, we have to make sure and finish up the current buffer.  As long as 
  54. ** the Buffer isn't empty we need to copy the Buffer to the WrapString and call Wrap.
  55. **
  56. DO Empty WITH 0
  57. CLEAR ALL
  58. RETURN
  59. * EOP Wraptest.PRG
  60.