home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / AGSPC1B2.ZIP / PRSCRMBL.PPS < prev    next >
Encoding:
Text File  |  1996-07-29  |  2.5 KB  |  83 lines

  1. ;----------------------------------------------------------------------------
  2. ; Copyright(C) 1996, The AEGiS Corporation
  3. ;----------------------------------------------------------------------------
  4. ;
  5. ; PROCEDURE PrintScramble()
  6. ;
  7. ; This procedure writes a string with a random scramble effect
  8. ;
  9. ; Warning : This procedure NEEDS to find spaces where the string will be
  10. ; printed... if not, a endless loop will occur...
  11. ; To ensure taht everything is ok, you should add a CLS before or someting
  12. ; like :
  13. ;       Print Space(len(Str))
  14. ;       Backup len(Str)
  15. ;----------------------------------------------------------------------------
  16. #lib
  17. Declare Procedure PrintScramble(String Str)
  18. Declare Procedure PS_RemCursor()
  19. Declare Procedure PS_Synchronize()
  20. Boolean PS_NoRemCursor
  21. Boolean PS_NoSynchro
  22.  
  23. ;----------------------------------------------------------------------------
  24. Procedure PrintScramble(String Str)
  25.  
  26. Integer v_int1, v_int2, v_int3, v_int4, v_int5, v_int6, v_int7
  27. String v_str1
  28.  
  29.  
  30. v_int4 = getx()     ; backup position
  31. v_int5 = gety()     ;
  32. v_int7 = curcolor() ; backup color
  33.  
  34. v_int2 = len(Str) ; length of string -> v_int2
  35.  
  36. While (1) Do
  37.     v_int1 = random(v_int2-1)+1 ; we randomly generate a number depending on
  38.                                 ; v_int2 (witch begins with the string len)
  39.     v_int3 = 0
  40.     v_int6 = 0
  41.     While (1) do                ; do until v_int6 is not v_int1 (random number)
  42.         inc v_int3
  43.         v_str1 = ScrText(v_int4+v_int3-1,v_int5, 1, False)
  44.         if (v_str1 = " ") inc v_int6 ; if char pointed is a space, inc v_int6
  45.         if (v_int6 = v_int1) Break
  46.     Endwhile
  47.     AnsiPos v_int4+v_int3-1,v_int5 ; ok so we have now the nth space (n = random)
  48.     v_str1 = Mid(Str, v_int3, 1) 
  49.     if (v_str1 != " ") Then        ; if the char to print is a space, print 
  50.         Print v_str1               ; a char 255, if not, print it...
  51.     else
  52.         Print chr(255)
  53.     endif
  54.     dec v_int2                     ; dec v_int2 so we cannot go over the 
  55.     if (v_int2 = 0) Break          ; amount of spaces available
  56.     PS_RemCursor()                   ; remove cursor
  57.     Delay 1                        ; add some delay
  58.     PS_Synchronize()                  ; wait for other end
  59.     Color v_int7                   ; restore color
  60. Endwhile
  61.  
  62. EndProc
  63.  
  64. Procedure PS_RemCursor()
  65.  
  66. If (!PS_NoRemCursor) Then
  67.     AnsiPos 1,23
  68.     Color 0
  69.     Print " "
  70.     Backup 1
  71. Endif
  72.  
  73. EndProc
  74.  
  75. Procedure PS_Synchronize()
  76.  
  77. If (!PS_NoSynchro) Then
  78.     While (Outbytes() > 0) Do
  79.     EndWhile
  80. Endif
  81.  
  82. EndProc
  83.