although I have used batch mode a little in the past I've a few questions for today. I've got a sub which uses the do-script capability in our 4D accounting package to construct with 4D code an AE sent to the perl's stdin. I'd really like to be able to check perl is in batch mode before invoking that do-script - there have been times in the past I started perl up normally and wondered why I wasn't getting any response. Q1) can I find out what mode Perl is running in? can I change the mode Perl is currently running in? [assuming there's no AE waiting in queues to be processed] Q2) this process is moderately slow because I have to send the 4D code line-by-line. Eventually I might be able to get the 4D software company to add a routine encapsulating this function, but has anyone got ideas on an improved way of getting information back into Perl? If 4D had ordinary file IO commands it might be quicker writing info into a temporary file. Q3) I wanted to write a little front end for perl using pick to allow for a choice of actions. The trouble is can I then switch to batch mode? I did try creating a text file containing one-line of perl and using AppleScript to execute that file in batch mode. It sort of works .. except stdin seems to be tied to the original thread(?) which invoked the AppleScript not to the thread from the file executed. What happens wrt to standard streams when Perl uses AppleScript to execute a perl script? Even though perl itself won't become multi-threaded until after 5.004, I'm guessing that I've created multiple threads of sorts within MacPerl. Q4) perhaps one approach is to not use stdin but a non-standard stream, but I don't understand the basic of AppleEvents well enough to make sense of these lines from MacPerl.frontend - Both Batch and Remote control/Duplex mode support opening further input and output streams as "Dev:AEVT:[4 byte code]". Standard input/output is "Dev:AEVT", standard error is "Dev:AEVT:diag". Note that these names are case sensitive! an example would help me a lot. Also how to create the handler needed. So the handler would be part of my Perl script, but the sender would be 4D constructing AppleEvents. I guess a perl routine using Dev:AEVT:[4 byte code] would be enough so I could capture and dissect the AppleEvent enough to see what 4D had to create. cheers Danny Thomas <D.Thomas@cmcb.uq.edu.au> out of interest's sake, this routine gets 4D to send the string stored in the variable dmt_stringo back to MacPerl. tell_4D is the routine passing one-line of 4D code into 4D via do-script # MacPerl can be started up in batch mode # tell application "MacPerl" to Do Script  # "MERLIN:Single User:Sapph.pl" mode Batch # so DATA apple events are fed into STDIN # I used the free/shareware AETracker utility, which can log all # AppleEvent activity, to debug this. The problem was my use of a string # literal as the parameter to PutTextParam. It seems to want 4D variables. sub send_4D_string { # one of my attempts to improve speed was to bundle these 4D # statements into a single script. It made a small improvement. if (1) { tell_4D('dmt_err := MakeAddress(\"McPL\"; dmt_addr)'); tell_4D('dmt_err := CreateAEVT(\"McPL\"; \"DATA\"; dmt_addr; dmt_aevt)'); # Perl's STDIN is line-oriented, so adding CR here makes sense tell_4D('dmt_stringo := dmt_stringo + dmt_cr'); tell_4D('dmt_err := PutTextParam(dmt_aevt; \"----\"; dmt_stringo)'); tell_4D('dmt_err := SendAppleEvent(dmt_aevt; dmt_reply; kAENoReply+NeverInteract; -1)'); tell_4D('dmt_err := DisposeDesc(dmt_reply)'); tell_4D('dmt_err := DisposeDesc(dmt_aevt)'); tell_4D('dmt_err := DisposeAddress(dmt_addr)'); } else { my ($script); $script = (<<END_SCRIPT); dmt_err := MakeAddress(\\"McPL\\"; dmt_addr)\\n dmt_err := CreateAEVT(\\"McPL\\"; \\"DATA\\"; dmt_addr; dmt_aevt)\\n dmt_stringo := dmt_stringo + dmt_cr\\n dmt_err := PutTextParam(dmt_aevt; \\"----\\"; dmt_stringo)\\n dmt_err := SendAppleEvent(dmt_aevt; dmt_reply; kAENoReply+NeverInteract; -1)\\n dmt_err := DisposeDesc(dmt_reply)\\n dmt_err := DisposeDesc(dmt_aevt)\\n dmt_err := DisposeAddress(dmt_addr) END_SCRIPT MacPerl::Answer($script); tell_4D($script); } }