Welcome to the forums! Excellent question. I'd argue that there should be a command, perhaps called GetStrategyName. I've put in a request to our development team.
In the meantime, I've created one for you (a little subroutine that I believe does what you need). As someone might notice in a sniff, when PAC Control's debug mode or PAC Terminal get the strategy's name from your controller, they're sending a "FILENAME" command to tcp port 22001 (assuming the default control engine port number). The command is followed by a CR (ASCII 13). The strategy name returned is preceded by 2 bytes of error code (both 0's if all is okay).
So, the code you'll find in the attached strategy/subroutine, looks something like this:
// This as assumes we want to talk to the host port, on 22001
sHandleValue = "tcp:127.0.0.1:22001";
// Open connection to port
nCHStatus = OpenOutgoingCommunication( chController );
if (IsCommunicationOpen( chController )) then // we opened the connection
// Here's where we send the command to the local or remote controller
sFORTHCommand = "FILENAME" + chr(13);
nCHStatus = TransmitString( sFORTHCommand, chController );
if (nCHStatus == 0) then // the transmit worked okay
// receive the reply from the controller (should be 2 bytes of 0 if all went okay)
nCHStatus = ReceiveNChars( sResponse, 2, chController );
// check for the 0x00 0x00 in the first 2 bytes
if((nCHStatus == 0) and (sResponse == 0) and (sResponse == 0)) then
// no error back from the remote controller, see how many characters are waiting
nNumChars = GetNumCharsWaiting( chController );
if ( nNumChars > 0 ) then // we have a non-zero length strategy name waiting for us, let's read those chars
//ReceiveNChars(Put in, Number of Characters, Communication Handle)
nCHStatus = ReceiveNChars( sStrategyName, nNumChars, chController );
CloseCommunication( chController );
I've attached a little sample strategy as well as just the subroutine, both built in 8.0 (in case anyone out there is still using older PAC Control). You should be able to open these in PAC Control 8.0 Basic or higher.
Hope that helps! Thanks for the excellent question.