You need to close the port I believe. <div><br></div><div>Robby<span></span><br><br>On Thursday, April 11, 2013, Steve Byan wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Section 3.7.4 "Regexp Matching" of the "Racket Reference" says in part:<br>
<br>
"If the optional output-port is provided as an output port, the part of input from its beginning (not start-pos) that precedes the match is written to the port. All of input up to end-pos is written to the port if no match is found. This functionality is most useful when input is an input port."<br>
<br>
Given this input file:<br>
<br>
multivac:~ smb$ cat /Users/smb/Library/Mail/V2/Mailboxes/personal.mbox/PMRC.mbox/Info.plist<br>
<?xml version="1.0" encoding="UTF-8"?><br>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "<a href="http://www.apple.com/DTDs/PropertyList-1.0.dtd" target="_blank">http://www.apple.com/DTDs/PropertyList-1.0.dtd</a>"><br>
<plist version="1.0"><br>
<dict><br>
<key>DisplayInThreadedMode</key><br>
<string>no</string><br>
<key>MailboxName</key><br>
<string>PMRC</string><br>
<key>SearchSortDescending</key><br>
<string>YES</string><br>
<key>SearchSortOrder</key><br>
<string>received-date</string><br>
<key>SortOrder</key><br>
<string>received-date</string><br>
<key>SortedDescending</key><br>
<string>NO</string><br>
</dict><br>
</plist><br>
<br>
I expect the following racket function to copy the entire input port to the output port:<br>
<br>
#lang racket<br>
<br>
(define (plist-file-match-sorted-descending plist-path)<br>
(let ([input-port (open-input-file plist-path)]<br>
[output-port (open-output-file (path-replace-suffix plist-path ".plist~") #:exists 'replace)])<br>
(if (regexp-match "<key>SortedDescending</key>\n\t<string>YES</string>" input-port 0 #f output-port)<br>
(displayln "sorted descending")<br>
(displayln "sorted ascending"))))<br>
<br>
(define test-path (string->path "/Users/smb/Library/Mail/V2/Mailboxes/personal.mbox/PMRC.mbox/Info.plist"))<br>
<br>
I apply the function to the file path:<br>
<br>
Welcome to DrRacket, version 5.3.3 [3m].<br>
Language: racket; memory limit: 128 MB.<br>
> (plist-file-match-sorted-descending test-path)<br>
sorted ascending<br>
><br>
<br>
But despite my expectations the resulting Info.plist~ file is empty:<br>
<br>
multivac:~ smb$ ls -l /Users/smb/Library/Mail/V2/Mailboxes/personal.mbox/PMRC.mbox/Info.plist~<br>
-rw-r--r-- 1 smb staff 0 Apr 10 17:09 /Users/smb/Library/Mail/V2/Mailboxes/personal.mbox/PMRC.mbox/Info.plist~<br>
<br>
<br>
What am I missing?<br>
<br>
Best regards,<br>
-Steve<br>
<br>
--<br>
Steve Byan <<a href="javascript:;" onclick="_e(event, 'cvml', 'stevebyan@me.com')">stevebyan@me.com</a>><br>
Littleton, MA 01460<br>
<br>
<br>
<br>
<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div>