The other day, I mentioned the Levenshtein distance FLL I wrote. At the time, I had forgotten to time it. I downloaded Bob Calco’s Fox implementation from Ed Leafe’s download page, and ran it 10K times: it took about 2.2 seconds each time.
Then I tested the C version. It ran in 0.1 seconds each time. I like this. :-)
As soon as I get a chance to replicate the steps I went through, I’ll post it: I don’t want to just toss the FLL up without commentary.
A while back, I wrote a short program showing how to use a ReportListener to change a field’s StringTrimming behavior. At the time, I used the GDIPlus foundation class which came out with VFP9. Now that Bo Durban and the VFPX folks have put together the GDIPlusX library, though, the code is a bit cleaner.
Read the rest of this entry »
Thanks-I-think to Ted Roche and Ed Leafe, who triggered this one over on ProFox. :-)
Imagine there’s no spreadsheets,
It’s easy if you try.
No .DOCs or templates.
To edit, just vi.
Imagine presentations
Given manually,
Ooh ooh, ooooh.
You may say I’m a zealot,
but there’s more than one or two.
I hope some day you’ll reformat
And start to run Ubuntu!
Downtown seattle on a friday night. The drummer across the street from the busstop pounds on his tubs. The crowd mills by the Cheesecake Factory.
–
Mobile Email from a Cingular Wireless Customer http://www.cingular.com
I recently decided to write a program to automate part of a monthly job we have here. We have a tab-delimited file that has really long field names, some of which bear little resemblance to the purpose of the field. Rather than maintain a separate list of which old field went with the new names, I used the inline comment ability that was added to VFP a version or two ago, and put each field on a separate line of a CREATE TABLE statement. However, I got tired of typing in each fieldname, and decided to save myself some work.
lcRefStructure = "longFieldName1" + CHR(9) ;
+ "longFieldName2" + CHR(9) ;
+ "reallyLongFieldName3"
lnFldCount = ALINES(laStru, lcRefStructure, .T., CHR(9))
_cliptext = 'CREATE TABLE NewDBF ( ; ' + CHR(13) + CHR(10)
FOR i = 1 TO lnFldCount
_cliptext = _cliptext + CHR(9) + " C()" ;
+ IIF(i < lnFldCount, ",", "") + " ;" ;
+ CHR(9) + "&" + "& " + laStru(i) + CHR(13) + CHR(10)
ENDFOR
_cliptext = _cliptext + ")"
This gives the output:
CREATE TABLE NewDBF ( ;
C(), ; && longFieldName1
C(), ; && longFieldName2
C() ; && reallyLongFieldName3
)
Which makes it easy to run down the list and fill in the specifics.
(Making sure that the format is still what you think you’re importing is left as an exercise for the reader. :-) )
Update: fixed missing tabs in lcRefStructure
I recently had cause to write my first Perl script. Since I had never written Perl before, I wasn’t sure it was the right thing to do, so I went to the perl.beginners newsgroup for help.
My initial post:
I have an ASCII list of addresses that I need to parse into something
more-friendly to the software I need to use it with. I usually use
Visual FoxPro, and can think of a few ways to do it there: it just
strikes me that perl probably has much easier ways to do it. :-)
The response:
Yes, it is trivial in Perl. Enable paragraph-mode (see: perldoc -q
paragraph), read the file one record at a time. Split the record on
the newline (see: perldoc -f split), print the resulting fields
separated by commas (see: perldoc -f join).
I downloaded ActivePerl and went to work. After reading up on the above functions, I came up with the following:
local $/ = "\n\n";
open(ADDRESSES, "c:\\temp\\testing.txt") or die "Could not open input file: $! !";
open(OUTCSV, "> c:\\temp\\test2.txt") or die "Could not open output file: $!";
while() {
$NextRec = "\"".join("\",\"", split("\n"))."\"\n";
print OUTCSV $NextRec;
}
Good grief, if I had realized it was that easy, I would have picked it
up long ago…
The response came back:
just FYI - it gets easier. if your addresses are stored in addr.txt:
$ perl -ln00e 'print join ",", map qq["$_"], split /\\n/' addr.txt
I answered:
I think you just broke my brain.
The response from the person who had originally helped me:
Welcome to Perl. :-)
It just occurred to me that there is an easier way to open an Explorer window to my current directory in Visual FoxPro than going down to the Address Bar I have parked in my Windows Taskbar. This can go into an Intellisense script if you like, instead of the PRG file/utility menu I’m using.
LOCAL loShellEx as _shellExecute OF HOME(1) + "ffc\_environ.vcx"
loShellEx = NEWOBJECT("_shellexecute", HOME(1) + "ffc\_environ.vcx")
loShellEx.ShellExecute(CURDIR())