FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

COMMUNICATION

Get the network name of an application


I would look into "Inside Macintosh: Networking."

Network nodes (mostly Mac's & network printers) make themselves "known" to the network by "registering" an "entity." An entity consists of an "object name" (which is usually the name of the Mac or the printer) plus an "entity type" string, which can be just about anything. Your Mac can (and typically does) register more than one entity (each with a different "entity type"). Also, an application can register entities too, for its own purposes.

At the "entity" level, you can do simple kinds of AppleTalk communications. If you want a higher-level protocol, you can make use of the "PPC Toolbox" routines ("PPC" stands for "Program-to-Program Communications" in this case). This level supports password access and a few other things that you don't get at the "entity" level.

PPC-level communication requires that your application "Open a port," which takes a "port type" string and a "port name" string, which you can pretty much set to whatever you like, as long as the programs you want to communicate with will recognize them. In addition, if you want users at remote mac's to be able to see your "port," then you need to enable Program Linking with the Sharing Setup control panel (if you've ever wondered what Program Linking was for, this is it).

I haven't looked at the STAZ-AE filters, so I don't know if the "networkname" you refer to is an "entity type" string, or a "port type" string, or a "port name" string, or something else entirely.

Below is a demo which calls PPCBrowser; this is a toolbox routine which lets you see all the PPC "ports" that are open on your local machine, plus any that are open on remote machines that have Program Linking enabled. Hope you find it useful.

Rick


COMPILE 0, _caseInsensitive

'======= constants ======
_PPCPortRec = 72
_locationNameRec = 104

DIM RECORD entityName '(See I.M. II-298)
  DIM 32 objStr$
  DIM 32 entityTypeStr$
  DIM 32 zoneStr$
DIM END RECORD _entityName

'Correct versions of constants misdefined by FB:
_myPortCreator = 38 '("portCreator" field of PPCPortRec type (I.M.
VI-7-15))
_myPortType = 42 '("portType" field of PPCPortRec type (I.M. VI-7-15))
_myNbpType = 2
_PIRname = 2 '("name" field of PortInfoRec type (I.M. VI-7-20))
_PPRname = 2 '("name" field of PPCPortRec type (I.M. VI-7-15))
'======= functions ============
'----------------------------------------------------
LOCAL FN
  PPCBrowser(@promptPtr&,@applListLabelPtr&,defaultSpecified,theLocnPtr&,thePortInfoPtr&,portFilter&,@theLocNBPTypePtr&)
'Call as follows:
'OSErr = FN PPCBrowser(prompt$, applListLabel$, defaultSpecified,@theLocation,
' @thePortInfo, portFilter&, theLocNBPType$)
'The parameter theLocation should be a 104-byte record. The parameter
'thePortInfo should be a 74-byte record.

  IF defaultSpecified THEN defaultSpecified = _zTrue'(set all bits)
  ` CLR.W -(SP)
  ` MOVE.L ^promptPtr&,-(SP)
  ` MOVE.L ^applListLabelPtr&,-(SP)
  ` MOVE.W ^defaultSpecified,-(SP)
  ` MOVE.L ^theLocnPtr&,-(SP)
  ` MOVE.L ^thePortInfoPtr&,-(SP)
  ` MOVE.L ^portFilter&,-(SP)
  ` MOVE.L ^theLocNBPTypePtr&,-(SP)
  ` DC.W $303C
  ` DC.W $0D00
  ` DC.W $A82B
  ` MOVE.W (SP)+,^OSErr
END FN = OSErr
'----------------------------------------------------
'======================
DIM theLocation.locationNameRec, thePortInfo.PPCPortRec
WINDOW 1: TEXT _monaco, 9
null$ = ""
OSErr = FN PPCBrowser(null$, null$, _false, @theLocation, @thePortInfo,0, null$)
CLS
PRINT "OSErr = "; OSErr
LONG IF OSErr = _noErr
  SELECT CASE theLocation.locationKindSelector
    CASE _ppcNBPLocation
      theObj$ = theLocation.nbpEntity.objStr$
      theType$ = theLocation.nbpEntity.entityTypeStr$
      theZone$ = theLocation.nbpEntity.zoneStr$
      PRINT "Location: "; theObj$, theType$, theZone$
   CASE _ppcNoLocation
     PRINT "Location: (Local computer)"
  END SELECT
  LONG IF PEEK(@thePortInfo + _authRequired)
    PRINT "authorization required"
  XELSE
    PRINT "no authorization required"
  END IF
  theScript = thePortInfo.PIRname.nameScript
  theName$ = thePortInfo.PIRname.PPRname$
  theSelector = thePortInfo.PIRname.portKindSelector
  PRINT "script:"; theScript
  PRINT "port name: "; theName$
  SELECT CASE theSelector
    CASE _ppcByString
      PRINT "port type string: "; thePortInfo.PIRname.portTypeStr$
    CASE _ppcByCreatorAndType
      DEFSTR LONG
      PRINT "portCreator: "; MKI$(thePortInfo.PIRname.myPortCreator&)
      PRINT "portType: "; MKI$(thePortInfo.PIRname.myPortType&)
    CASE ELSE
      PRINT "Unknown portKindSelector:"; theSelector
  END SELECT

END IF
DO
UNTIL MOUSE(_down)