Created
March 10, 2014 07:12
-
-
Save myrkvi/9460685 to your computer and use it in GitHub Desktop.
Filler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/gui/base) | |
; Create the main window. | |
(define frame (new frame% [label "Filler"] | |
[min-width 300] | |
[min-height 240] | |
[style '(no-resize-border)] | |
)) | |
; Create the status line | |
(send frame create-status-line) | |
; Create the text field for the file name. | |
(define file-text (new text-field% [parent frame] | |
[label "File:\t\t"] | |
[init-value "filled.txt"] | |
)) | |
; Create the text field for the filler text | |
(define filler-text (new text-field% [parent frame] | |
[label "Filler:\t"] | |
[init-value "egg\n&\nbacon"] | |
[style '(multiple)] | |
)) | |
; Select amount of times to repeat the task. | |
(define repeat-text (new text-field% [parent frame] | |
[label "Repetitions:\t"] | |
[init-value "500"] | |
)) | |
; Create the button to start the filler. | |
(define filler-button (new button% [parent frame] | |
[label "Fill!"] | |
[callback (lambda (button event) | |
(send frame set-status-text "Started ...") | |
(let ([file (open-output-file (send file-text get-value) #:exists 'replace)] | |
[fill (send filler-text get-value)] | |
[f (eval (read (open-input-string (send repeat-text get-value))))]) | |
(for ([i f]) | |
(display fill file) | |
(display "\r\n" file)) | |
(close-output-port file)) | |
(send frame set-status-text "Finished.") | |
)])) | |
(send frame show #t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment