-- ping broadcast IP (x.x.x.255) to update device list for arp
-- use arp to get IP addresses of all active devices
set IPlines to do shell script "ping -t 10 $(ifconfig -u | grep broadcast | rev | cut -d' ' -f1 | rev | head -1) > /dev/null 2>&1 & echo > /dev/null; arp -a | cut -d'(' -f2 | cut -d')' -f1 | tr '
' ',' | rev | cut -c 2- | rev"
-- properly format list with IP addresses of active devices
set tid to AppleScript's text item delimiters -- get present (original) state
set AppleScript's text item delimiters to ","
set IPList to text items of IPlines
set AppleScript's text item delimiters to tid -- reset to original state
set afpServerList to {}
-- call afpgetstatus with timeout of 2 sec (to prevent long wait for non-responsive IP) for each IP address to output server status of any active AFP2-only servers
-- filter output to print only IP address and server name
-- create list with available AFP2-only servers for dialog
tell application (path to frontmost application as text) to set afpServerChoice to choose from list afpServerList with title "afpfs-ng-mac <20> Server Selection" with prompt "Choose an AFP2.x server:" OK button name "Continue <20>"
tell application (path to frontmost application as text) to display dialog "No active AFP2.x servers found." with title "afpfs-ng-mac <20> Error" buttons {"OK"} default button "OK" with icon "/usr/local/afpfs-ng-mac/icon/server.icns" as POSIX file
tell application (path to frontmost application as text) to display dialog "No AFP2.x volumes found on <20>" & afpServerName & "<22>." with title "afpfs-ng-mac <20> Error" buttons {"OK"} default button "OK" with icon "/usr/local/afpfs-ng-mac/icon/shared_volume.icns" as POSIX file
tell application (path to frontmost application as text) to set afpVolumeChoice to choose from list afpVolumeList with title "afpfs-ng-mac <20> Volume Selection" with prompt "Choose a volume from <20>" & afpServerName & "<22>:" OK button name "Mount"
-- create mount point, load macfuse if not yet running, load afpfs daemon
-- export variables for beeing processed by afpfs-ng-mac.mount_cmd.app
-- launch afpfs-ng-mac.mount_cmd.app to create mounts and aliases
do shell script "mkdir /usr/local/afpfs-ng-mac/mount/\"" & afpMountNameRAW & "\" && if ! test -e /dev/macfuse0; then /Library/Filesystems/macfuse.fs/Contents/Resources/load_macfuse && /usr/local/bin/afpfsd; fi