Computers: December 2002 Archives
So the note inside said they fixed the problem, replacing the logic board (I am now on this computer's third logic board, though I think this replacement was likely unnecessary ... read on).
I try to boot the computer on the battery. Once again, it failed. Sigh. They simply did not fix the problem they caused the last time. If you recall, I sent in the computer to get the optical drive fixed, and it came back not powering with the battery. They apparently didn't even TEST to see if the problem THEY CAUSED was fixed this time around. So I get the computer back from its second "repair" with the exact same symptom as before. It boggles the mind. "Computer won't work with battery" apparently means "just replace the logic board, don't bother trying to use the computer with the battery."
And because their systems are being upgraded, I probably won't get a box to ship the computer back for several days.
The only good thing about the state of the computer is that it appears to work fine if no battery is installed, so I can at least work on setting the computer up (I am reinstalling everything, including fink, perl, etc.).
Now Playing: Closer To You - The Wallflowers (Red Letter Days)
Now Playing: How Good It Can Get - The Wallflowers (Red Letter Days)
But um ... now it won't use the battery. Having the battery in the computer while powered with the AC can cause the computer to freeze. Pressing on the battery compartment causes the AC adapter's light (which tells if there is power, and if the battery is charging) to flicker. Smells like a bad connection. I open it up and the two screws holding the connector to the battery are not tightened. Tightening them makes the flicker go away, but despite resetting the Power Manager, I still can't power up using the battery.
Back to Apple tomorrow. If I am lucky, they fix it and return it on Thursday, and I get it back Friday. With no new or old problems. :-)
http://sf.net/projects/macperl/
http://www.cpan.org/authors/id/C/CN/CNANDOR/
It fixes the bugs with AEDesc, POD, xsubpp, building on Mac OS X 10.1/gcc2/etc. A binary distribution for perl 5.6 is available from SourceForge.net. Thanks to all who have helped, and please submit bugs to SourceForge.net if you have any to report.
This is the last release for a little while; I am going to focus on fixing some of the outstanding bugs listed in the documentation. Patches welcome. Enjoy!
Now Playing: Run - Brett Williams & In Reach (Power & Promise)
Since that was working, I went ahead and did the second phase, which is autogenerating
I refactored the Makefile.PLs to share a common.pl file, because there's just too much now. Most of the Makefile.PLs are reduced to:
use File::Spec::Functions;And, I made a few changes to get it to compile under gcc2 (for Mac OS X 10.2, anyway). Hopefully it will work for 10.1.x users, too. Thanks to Ken Williams and Paul McCann for pointing that out.
use strict;
do(catfile(updir(), 'common.pl'));
domakefile();
I am going to sit on this a few days and release it as 0.03 next week. It'd be nice to get that "GUSI" bug fixed in the meantime. We'll see.
Now Playing: St. John - Aerosmith (Permanent Vacation)
- Fix my GUSI emulation bugs so FSSpecs can be created without file existing
- Release 0.03
- Better test suite (esp. Files, MoreFiles, AppleEvents, OSA)
- Work on new system for releasing modules (not necessary, but would be nice :)
- Release ported Mac::OSA::Simple
- Release ported Mac::AppleEvents::Simple; this may require some work to get remote Apple events working (they currently don't, I think the way to do this changed in Mac OS X, and this may come later ... remote events are not as critical at the moment)
- Port and release Mac::Apps::Launch; launching and quitting applications (and finding them!) has changed in various ways, may also require changes to Mac::Processes
- Port and release Mac::Glue (not a lot to do once all the other pieces are ported!)
Now Playing: Burning Down - King's X (Gretchen Goes To Nebraska)
Now Playing: Over My Head - King's X (Gretchen Goes To Nebraska)
#!/usr/bin/perl -w
use POSIX 'SIGTERM';
use Mac::Processes;
while (my($psn, $psi) = each %Process) {
next unless $psi->processName eq 'Mozilla';
kill SIGTERM, GetProcessPID($psn);
last;
}
Now Playing: What A Wonderful World - Russ Taff (A Christmas Song)
my $desc = OSAGetSource($component, $scriptid, typeChar);But even on Mac OS X, it is returned with Mac newlines, CR, instead of Unix newlines, LF. Even if the input source was with Unix newlines.
my $source = $desc->get;
Mac::OSA::Simple works pretty well, though I need to release a new version to support Mac OS X. I can do stuff like:
use Mac::OSA::Simple;Calling play() and pause() are much much faster than calling DoAppleScript($script) over and over again, because the compilation phase of the AppleScript is time-consuming. This kind of thing should work fine now, but return values are broken (the way AEPrint() returns data has changed, and I was using that instead of $desc->get), as is saving a script to disk (e.g., $pause->save($filename); my $script = load_osa_script($filename, 1);; this is related to the problem of my current FSSpec routines requiring files to exist, which needs to be fixed).
my $play = compile_applescript('tell app "iTunes" to play');
my $pause = compile_applescript('tell app "iTunes" to pause');
sub play { $play->execute }
sub pause { $pause->execute }
So I won't be releasing the new Mac::OSA::Simple too soon; I want to first see about addressing my issues with the FSSpec routines, and I need to revamp how I release modules (bug reporting, CVS, releases on CPAN and SourceForge.net, etc.).
I'll be giving a demo of this stuff tomorrow at the Boston.pm meeting.
Now Playing: You Will Go Free - Tonio K. (Romeo Unchained)
Eventually I'll port the Journal SOAP stuff over. Everything about the API should stay the same except for the proxy (soap.pl instead of journal.pl), though we can probably hack it to make it work with either one, for awhile anyway.
Call him Frying Pan Man? The reference is both too obvious and not obvious enough, at the same time. Some people will get it and think it it stupid, some will not understand it at all. References don't make good superhero names, I think.
I don't have Apple events to remote machines working. I am not entirely sure why. I do know I have problems with it in Script Editor too, so it might not even be a problem with the Perl code at all. I think it might be, though: I can't find typeTargetID (which is the address type I use in Mac OS to send remote calls) anywhere in any of the headers. I think the method to do this has changed; maybe remote events use SOAP, maybe something else? I'll investigate later.
I also have a problem that is killing me with creating AEDescs. I have this code:
Ptr theData;Now, *data contains "hi" and GetHandleSize(data) is 2. theLength is 2. But after AEGetDescData(), theData contains "hi5{" and strlen(theData) is 4. No matter what I do, if the string is 2 bytes, "5{" is tacked onto the end. If it is 3, "{" is tacked on. If the data is 1 or more than 3 bytes, it comes out fine. It's freaking me out.
Size theLength;
Handle data;// contains "hi"
OSType type;// contains "TEXT"
AEFail(AECreateDesc(type, *data, GetHandleSize(data), &RETVAL));
// test this, see what we have
theLength = AEGetDescDataSize(&RETVAL);
theData = malloc(theLength);
if (theData != NULL) {
AEFail(AEGetDescData(&RETVAL, theData, theLength));
printf("%d:%s:%d\n", theLength, theData, strlen(theData));
}
So, I have bunches of little bugs like this. The GUSI* routines are working pretty well, but totally bail if the target file does not exist, which is a very wrong thing to do. It might take total reengineering. Yuck.
The AEBuild error code for $@ is acting up a little; for some reason it is displaying an error when there should be none. But I am resisting the temptation to look into it now, and instead am just noting it, as I am taking the weekend off.
I also need to work on Mac::AppleEvents::Simple some, though it seems to be fine except for the remote calls. So far. I'm sure I'll find more. Mac::Apps::Launch and Mac::Processes need an overhaul for launching processes on Mac OS X. The old calls I use sorta work, but not really, and they are slow.
I hope to release Mac::Carbon 0.02 next week, and then continue to iron out these other bugs and things for a Mac::Carbon 0.03 next year, along with updates to Mac::Apps::Launch and Mac::AppleEvents::Simple (sold separately). Then, when I am satisfied it is working reasonably well, I'll do Mac::Glue.
use Mac::AppleEvents;And:
use Mac::Errors;
$e = AEBuildAppleEvent(qw(aevt odoc sign MACS), -1, 0, "asdasd");
print "$Mac::Errors::MacError: $@" if $!;
__END__
AEBuildDesc and friends detected a syntax error: Missing ":" after keyword in record at character 6
use Mac::AppleEvents;
use Mac::Errors;
$e = AEBuildAppleEvent(qw(aevt odoc sign MACS), -1, 0,
q"'----':obj { want:type(cobj), from:null(), form:enum(name), seld:TEXT(@)",
"Orr:"
);
print "$Mac::Errors::MacError: $@" if $!;
__END__
AEBuildDesc and friends detected a syntax error: Expected "," or "}" at character 72
Now Playing: I'm Forgettable - Brak (Brak Presents The Brak Album)
So today, I get it working, and I try a simple script:
use Mac::AppleEvents;And sure enough, it activates the Finder. This is the equivalent of the AppleScript:
$evt = AEBuildAppleEvent(qw(misc actv sign MACS), -1, 0, "");
AESend($evt, kAENoReply);
tell app "Finder" to activateSweet. I've even tried some more complex things, opening a directory in the Finder, using the Mac::AppleEvents::Simple frontend:
use Mac::AppleEvents::Simple ':all';Or, using aliases:
$evt = build_event(qw(aevt odoc MACS),
q{'----':obj { want:type(cobj), from:null(), form:enum(name), seld:TEXT(@)}}
"Orr:Users:pudge:" # yes, AEGizmos requires HFS paths
);
$evt->send_event(kAENoReply);
use Mac::AppleEvents::Simple ':all';All looks good so far. But, you may ask, why kAENoReply? Sure, I don't need the reply, but why bother not waiting, as per the default? There's the big remaining problem: I can't receive a reply. I have an idle proc that appears to be working -- as is needed to receive a reply -- but it's not getting the event back. I was afraid of this. In Mac OS, you need to set a flag that says your application can receive high-level events (such as Apple events). But how to do this for perl? No idea. Working on a solution, but in the meantime, polishing and playing.
use Mac::Files;
$evt = build_event(qw(aevt odoc MACS), q{'----':alis(@@)}, NewAlias("/Users/pudge/")); $evt->send_event(kAENoReply)'
I also still need to port the AESubDescs (for subdescriptors) and AEStreams (an OO interface to handling Apple event data) stuff, but they are rarely used, and are a lower priority than just getting this to work. I'll be more than happy to add them back in later, if I can.
Now Playing: Found a Home - Jon Gibson (Forever Friends)
$ perl -Iblib/arch -Iblib/lib -MMac::AppleEvents -e1They are apparently related to C++ (AppleEvents.xs links to PerlAEUtils.cp) and gcc and linking. I just don't really have a clue as to how to deal with it.
dyld: perl Undefined symbols:
__ZdlPv
__Znwm
___gxx_personality_v0
Now Playing: Art Carney's Dream - The Swirling Eddies (Zoom Daddy)