home *** CD-ROM | disk | FTP | other *** search
/ Univers Interactif 3 / INTERACTIF.BIN / pc / planeten / internet / hyperftp / background_2574.txt < prev    next >
Text File  |  1990-09-07  |  38KB  |  1,401 lines

  1. -- background: 2574 from stack: in
  2. -- bmap block id: 3300
  3. -- flags: 4000
  4. -- background id: 0
  5. -- name: Main
  6. ----- HyperTalk script -----
  7. -- HyperFTP background script.  ΓÇ£Most of the smarts is here.ΓÇ¥
  8. -- by Douglas Hornig, @ 1990 by Cornell University
  9.  
  10. -- selectlineXCMD by Phil Beisel, ┬⌐ Apple Computer, Inc. 1989
  11. -- FileName, NewFileName by Steve Maller, Andrew Gilmartin, Jon Pugh
  12. --   ┬⌐ 1987 Apple Computer & Brown University
  13. -- PopUpMenu by Andrew Gilmartin ┬⌐ Brown University 1989
  14. -- TCPNameToAddr, TCPSend, TCPRecvUpTo, TCPState, TCPRelease, TCPClose,
  15. --   TCPPassiveOpen by Harry Chesley ┬⌐ Apple Computer, Inc. 1989
  16. -- Password, LeafName by Kevin Calhoun
  17. --   ┬⌐1989 by the Trustees of Dartmouth College
  18. -- TCPGetAddr, FTPxfer, FTPMacBinXfer, FTPhqXfer, TCPSendUrgent,
  19. --   Translate by Douglas Hornig ┬⌐ Cornell University 1990
  20. -- Thanks to Gaige B. Paulsen of NCSA, for sample MacBinary code.
  21. -- Thanks to Doug Moore of Rice University, for sample BinHex code.
  22.  
  23. on idle
  24.   global connID, dataID, sLine, partLine, diagTxt
  25.  
  26.   -- Release the data connection if it is closed
  27.   if dataID is not empty then
  28.     get TCPState( dataID )
  29.     if it contains "close" then
  30.       TCPRelease dataID
  31.       put empty into dataID
  32.     end if
  33.   end if
  34.  
  35.   -- Check the status of the communications connection
  36.   if connID is empty
  37.   then get "no connection" else get TCPState( connID )
  38.   checkState it
  39.   if it is not "established" then exit idle
  40.  
  41.   -- Some messages from the host are received at idle time:
  42.   repeat
  43.     get TCPRecvUpTo( connID, linefeed, zero, partLine )
  44.     if it = partLine then exit repeat -- no new messages
  45.     diagMsg it -- display in diagnostic window
  46.  
  47.     if char 1 of it is "┬º" then -- error from MacTCP XCMD?
  48.       TCPRelease connID -- abort the connection
  49.       put empty into connID
  50.       exit idle
  51.     end if
  52.  
  53.     if char length( it ) of it is not linefeed then
  54.       put it into partLine
  55.       exit repeat -- partial line: wait for the rest
  56.     end if
  57.     put empty into partLine -- got a whole line
  58.  
  59.     get word 1 of it -- extract the FTP response code
  60.     if it is 220 then askUser
  61.     else if it is 221 then quitIt
  62.     else if it is 230 then getDir
  63.     else if it is 331 then askPass
  64.     else if it is 530 then noUser
  65.   end repeat
  66.  
  67.   -- Change the display depending on if an entry is selected or not:
  68.   if sLine is zero then -- nothing selected
  69.     set the textFont of bg btn "ReceiveΓǪ" to "Chicago Gray"
  70.     set the textFont of bg btn "Display"  to "Chicago Gray"
  71.     set the textFont of bg btn "Delete"   to "Chicago Gray"
  72.     set the name of bg btn id 62 to "SetΓǪ"
  73.   else
  74.     set the textFont of bg btn "ReceiveΓǪ" to "Chicago"
  75.     set the textFont of bg btn "Display"  to "Chicago"
  76.     set the textFont of bg btn "Delete"   to "Chicago"
  77.     if the short name of bg btn id 62 is not "Set" -- so selection won't flash
  78.     then set the name of bg btn id 62 to "Set"
  79.     if visible of bg fld "Full Dir"
  80.     then get "Full Dir" else get "Dir List"
  81.     selectlineXCMD "bkg fld" && quote & it & quote, sLine
  82.   end if
  83.  
  84.   get the number of lines in diagTxt
  85.   if it > 16 then delete line one to it - 16 of diagTxt
  86. end idle
  87.  
  88. -- Handle changes in the communications state
  89. on checkState theState
  90.   global connID, sLine, diagTxt, diagScroll, partLine
  91.  
  92.   if theState = bg fld "State" then exit checkState -- no status change
  93.   lock screen
  94.  
  95.   if theState is "no connection" then
  96.     put empty into bg fld "Dir List"
  97.     put empty into bg fld "Full Dir"
  98.     put empty into bg fld "Path"
  99.     put empty into bg fld "Diag"
  100.     put empty into diagScroll
  101.     put empty into partLine
  102.     put zero into sLine
  103.  
  104.     set the name of bg btn id 29 to "Connect"
  105.     set the lockText of bg fld "Host Name"  to false
  106.     set the visible  of bg btn "Hide Xfers" to true
  107.  
  108.     set the textFont of bg btn "SendΓǪ"    to "Chicago Gray"
  109.     set the textFont of bg btn "ReceiveΓǪ" to "Chicago Gray"
  110.     set the textFont of bg btn "Display"  to "Chicago Gray"
  111.     set the textFont of bg btn "Delete"   to "Chicago Gray"
  112.     set the textFont of bg btn id 62      to "Chicago Gray" -- "Set"
  113.     set the textFont of bg btn "CreateΓǪ"  to "Chicago Gray"
  114.     set the icon of bg btn "Parent Dir" to "Sml Up Arrow Gray"
  115.   else
  116.     set the lockText of bg fld "Host Name" to true
  117.   end if
  118.  
  119.   if theState is "established" then
  120.     set the name of bg btn id 29 to "Disconnect"
  121.     set the visible of bg btn "Hide Xfers" to false
  122.  
  123.     set the textFont of bg btn "SendΓǪ"   to "Chicago"
  124.     set the textFont of bg btn id 62     to "Chicago" -- "Set"
  125.     set the textFont of bg btn "CreateΓǪ" to "Chicago"
  126.     set the icon of bg btn "Parent Dir" to "Sml Up Arrow"
  127.   end if
  128.  
  129.   if theState contains "close" then
  130.     TCPClose connID
  131.     TCPRelease connID
  132.     put empty into connID
  133.   end if
  134.  
  135.   if theState contains "waiting"
  136.   then set the name of bg btn id 29 to "Disconnect"
  137.  
  138.   put theState into bg fld "State"
  139.   unlock screen
  140. end checkState
  141.  
  142. -- Initialize various things
  143. on openStack
  144.   global connID, dataID, partLine
  145.  
  146.   if the version < 1.2 then -- check the HyperCard version
  147.     answer "You must have HyperCard version 1.2 or later."
  148.     go back
  149.     exit openStack
  150.   end if
  151.  
  152.   lock screen
  153.   put empty into connID
  154.   put empty into dataID
  155.   put empty into partLine
  156.   put empty into bg fld "State" -- set "no connection" state on idle
  157.   put "ASCII" into bg fld "Mode" -- default to ASCII xfer mode
  158.  
  159.   if item 2 of the loc of card window Γëñ 20 then hide menuBar
  160.   hide msg box
  161. end openStack
  162.  
  163. -- Finish up various things
  164. on closeStack
  165.   global connID, dataID
  166.  
  167.   if connID is not empty then
  168.     TCPRelease connID
  169.     put empty into connID
  170.   end if
  171.  
  172.   if dataID is not empty then
  173.     TCPRelease dataID
  174.     put empty into dataID
  175.   end if
  176.  
  177.   if the freeSize of this stack ΓëÑ 40960 then -- 40K free space?
  178.     diagMsg "Compacting the stackΓǪ"
  179.     put the userLevel into saveLevel
  180.     if saveLevel < 3 then set the userLevel to 3
  181.     send "doMenu Compact Stack" to HyperCard
  182.     set the userLevel to saveLevel
  183.   end if
  184.  
  185.   show menuBar -- restore the menuBar in case we hid it
  186. end closeStack
  187.  
  188. -- Open a data connection for transferring a file.
  189. -- Tells the host the data conn. port address and the transfer type.
  190. -- The type code is "A"(ASCII), "I"(image), "M"(MacBinary), "H"(BinHex)
  191. on openData typeCode
  192.   global dataID
  193.  
  194.   -- MacBinary = Binary and BinHex = ASCII for our purposes here:
  195.   if typeCode is "M" then put "I" into typeCode
  196.   else if typeCode is "H" then put "A" into typeCode
  197.  
  198.   -- Make sure any previous data connection is released
  199.   repeat until dataID is empty
  200.     idleCursor
  201.     idle
  202.   end repeat
  203.  
  204.   put TCPPassiveOpen( 0, 0, 0 ) into dataID -- create a new data conn.
  205.  
  206.   if dataID contains "fail" then
  207.     diagMsg dataID -- display the error msg
  208.     put empty into dataID
  209.     exit to HyperCard -- don't continue with file transfer
  210.   end if
  211.  
  212.   wait until TCPState( dataID ) contains "waiting" -- happens asynch.
  213.  
  214.   sendLine "PORT" && TCPGetAddr( dataID, "local" ) -- get local address
  215.   put char 1 of getLine() into resp
  216.   if resp is "2" then
  217.     sendLine "TYPE" && typeCode -- specify the transfer mode
  218.     put char 1 of getLine() into resp
  219.  
  220.     if resp is "2" and typeCode is "I" then
  221.       sendLine "TYPE L 8" -- set byte length to 8 for Binary
  222.       get getLine() -- ignore the response
  223.     end if
  224.   end if
  225.  
  226.   if resp is not "2" then
  227.     beep
  228.     TCPClose dataID
  229.     exit to HyperCard -- don't continue with file transfer
  230.   end if
  231. end openData
  232.  
  233. -- Call when we're done with a data connection (transfer completed)
  234. on closeData
  235.   global dataID
  236.  
  237.   TCPClose dataID -- close and let idle handler take care of release
  238.   if the result is not empty then diagMsg the result
  239. end closeData
  240.  
  241. -- Hang out while the data connection is being established
  242. function WaitForDataCon
  243. global dataID
  244.  
  245. repeat until TCPState( dataID ) is "established"
  246.   if TCPState( dataID ) contains "close" then return false
  247.   idleCursor
  248. end repeat
  249.  
  250. return true -- signal connection is established
  251. end WaitForDataCon
  252.  
  253. -- Return a line from the communications conn. 15 second time limit.
  254. function getLine
  255. global connID
  256.  
  257. repeat 15 times
  258.   set the cursor to busy
  259.   get TCPRecvUpTo( connID, linefeed, 60, empty )
  260.   if it is not empty then exit repeat
  261. end repeat
  262.  
  263. diagMsg it -- display the message
  264. return it
  265. end getLine
  266.  
  267. -- Send some text (with return & linefeed) over comm. connection
  268. on sendLine text
  269.   global connID
  270.  
  271.   TCPSend connID, text & return & linefeed
  272. end sendLine
  273.  
  274. -- Call idleCursor repeatedly while waiting for something.
  275. on idleCursor
  276.   global lastTurn
  277.  
  278.   get the seconds
  279.   if it Γëá lastTurn then
  280.     set the cursor to busy -- spin the ball
  281.     put it into lastTurn
  282.   end if
  283. end idleCursor
  284.  
  285. -- Request a user ID.
  286. on askUser
  287.   ask "User name:" with "anonymous"
  288.   if it is not empty then sendLine "USER" && it
  289. end askUser
  290.  
  291. -- Request a user password
  292. on askPass
  293.   lock screen
  294.   get Password( "Enter the password:" )
  295.   unlock screen
  296.   if it is not empty then sendLine "PASS" && it
  297. end askPass
  298.  
  299. -- Host requested end of session
  300. on quitIt
  301.   global connID
  302.  
  303.   TCPClose connID
  304.   if the result is not empty then diagMsg the result
  305. end quitIt
  306.  
  307. -- called by getDir with a parameter "short" or "long".
  308. -- "short" puts an NLST file list into the field "Dir List",
  309. -- "long" puts a LIST file list into the field "Full DIr"
  310. on readDir shtLng -- shtLng = short or long
  311.   global dataID
  312.  
  313.   put empty into DirList
  314.   openData "A" -- use ASCII mode transfer
  315.   if shtLng is "long" then sendLine "LIST" else sendLine "NLST"
  316.  
  317.   if char 1 of getLine() is "1" then
  318.     if WaitForDataCon() then
  319.       FTPxfer dataID, "receive", "ascii" -- get the directory list
  320.       get the result
  321.  
  322.       if char 1 of it is not "┬º" then put it into DirList
  323.       else diagMsg it
  324.     end if
  325.   end if
  326.  
  327.   closeData -- close the data port
  328.   lock screen
  329.   if shtLng is "long" then
  330.     get line one of DirList
  331.     if word one of it is "Total" or offset( ":<", it ) is not zero
  332.     then delete line one of DirList -- Unix and Tops-20 add a top line
  333.  
  334.     put "Full Dir" into fldName
  335.   else put "Dir List" into fldName -- shtLng is "short"
  336.  
  337.   get length( DirList )
  338.   if it >= 29900 then delete char 29900 to it of DirList
  339.   put DirList into bg fld fldName
  340.   set the scroll of bg fld fldName to zero
  341.   unlock screen
  342.  
  343.   if DirList is not empty then get getLine() -- get final response
  344. end readDir
  345.  
  346. -- Get a new directory list from the host.  Also requests path.
  347. on getDir
  348.   global PWDcmd, sLine
  349.  
  350.   put zero into sLine -- no entry is selected
  351.   put empty into bg fld "Full Dir"
  352.   readDir "short"
  353.   if visible of bg fld "Full Dir" then readDir "long"
  354.  
  355.   -- Update the path name field: Try both "PWD" and "XPWD" commands.
  356.   if PWDcmd is empty then put "PWD" into PWDcmd
  357.  
  358.   repeat 2 times -- may have to try both "PWD" and "XPWD"
  359.     sendLine PWDcmd -- send the command
  360.     put getLine() into pathMsg -- get the result
  361.  
  362.     get word 1 of pathMsg
  363.     if it is 226 or it is 250
  364.     then put getLine() into pathMsg -- skip any left-over msg from NLST
  365.  
  366.     if char 1 of pathMsg is "2" then exit repeat
  367.  
  368.     if PWDcmd is "PWD" -- try the other command
  369.     then put "XPWD" into PWDcmd
  370.   else put "PWD"  into PWDcmd
  371. end repeat
  372.  
  373. get offset( quote, pathMsg ) -- extract the path name (hopefully)
  374. if it is not zero then
  375.   delete char 1 to it of pathMsg
  376.   get offset( quote, pathMsg )
  377.   put char 1 to it-1 of pathMsg into bg fld "Path"
  378. else
  379.   put empty into bg fld "Path" -- couldn't get the path
  380. end if
  381. end getDir
  382.  
  383. -- Host didn't get user ID
  384. on noUser
  385.   send mouseUp to bg btn "Disconnect"
  386. end noUser
  387.  
  388. -- Request new directory on the host
  389. function changeDir remoteFile
  390. put offset( ".dir", remoteFile ) into dirOffset
  391. if dirOffset Γëá 0 then
  392.   get char dirOffset + 4 of remoteFile
  393.   if it is ";" or it is empty -- fix VMS directory names
  394.   then delete char dirOffset to length( remoteFIle ) of remoteFile
  395. end if
  396.  
  397. sendLine "CWD" && remoteFile
  398.  
  399. get char 1 of getLine()
  400. if it is "2" or it is "3" then -- positive response?
  401.   getDir -- update the Entries and Path fields
  402.   return true
  403. end if
  404.  
  405. return false -- didn't work
  406. end changeDir
  407.  
  408. -- Delete a file or directory on the host
  409. on deleteFile remoteFile
  410.   answer "Really delete ΓÇÿ" & remoteFile & "ΓÇÖ?" with "OK" or "Cancel"
  411.   if it is "Cancel" then exit deleteFile
  412.  
  413.   sendLine "DELE" && remoteFile
  414.   if char 1 of getLine() is "2" then getDir
  415. end deleteFile
  416.  
  417. -- Display a file from the host
  418. on showText remoteFile, theText
  419.   lock screen
  420.   go card "Show Text"
  421.   put theText into cd fld "The Text"
  422.   set the scroll of cd fld "The Text" to zero
  423.   put remoteFile into cd fld "File Name"
  424.   set the visible of cd fld "Too Long" to ( length( theText ) ΓëÑ 29900 )
  425.   unlock screen with visual effect iris open fast
  426. end showText
  427.  
  428. -- Return a single-character flag for transfer mode.
  429. function xferType
  430. get bg fld "Mode"
  431. if it is "ASCII"     then return "A"
  432. if it is "Binary"    then return "I" -- Image
  433. if it is "MacBinary" then return "M"
  434. return "H" -- must be BinHex
  435. end xferType
  436.  
  437. -- Send an ABORT command to the host.  Ir must be preceeded by a Telnet
  438. -- Interrupt Process and a Synch (Data Mark in an Urgent packet.
  439. on sendABOR
  440.   global connID, dataID
  441.  
  442.   TCPSendUrgent connID, NumToChar(255) & NumToChar(244) & NumToChar(255) & NumToChar(242) -- send urgent IP & synch
  443.   sendLine "ABOR" -- then send abort command
  444.   repeat while TCPState( dataID ) is "established"
  445.     if TCPRecvUpTo( dataID, empty, zero, empty ) is not empty
  446.     then set cursor to busy -- read any left over data
  447.   end repeat
  448. end sendABOR
  449.  
  450. -- Transfer a file from the host.
  451. -- Pass "file" or "memory" in fileMemory.
  452. on receiveFile remoteName, fileMemory
  453.   global dataID
  454.  
  455.   if fileMemory is "memory" then
  456.     put "A" into xType
  457.     put empty into localFile -- signal receive into memory
  458.   else -- fileMemory is "file"
  459.     put bg fld "Mode" into theMode
  460.     put empty into otherMode
  461.     get length( remoteName )
  462.     get char it-2 to it of remoteName -- get last 3 chars of remoteName
  463.  
  464.     if it is "bin" and theMode is not "MacBinary"
  465.     then put "MacBinary" into otherMode
  466.   else if it is "hqx" and theMode is not "BinHex"
  467.   then put "BinHex" into otherMode
  468. else if it is not "bin" and it is not "hqx" and ( theMode is "MacBinary" or theMode is "BinHex" )
  469. then put "ASCII" into otherMode
  470.  
  471. if otherMode is not empty then
  472.   answer "Use" && theMode && "or" && otherMode && "transfer mode?" with theMode or otherMode or "Cancel"
  473.   if it is "Cancel" then exit receiveFile
  474.   put it into bg fld "Mode"
  475. end if
  476. put xferType() into xType
  477.  
  478. if xType is "A" or xType is "I" then
  479.   -- Note: MacBinary and BinHex ask for their own localFile name
  480.   put remoteName into namePrompt
  481.   put NewFileName( "Save as:", namePrompt ) into localFile
  482.   if localFile is empty then exit receiveFile -- pressed cancel
  483. end if
  484. end if
  485.  
  486. openData xType -- open data port using selected xfer type
  487. sendLine "RETR" && remoteName
  488.  
  489. if char 1 of getLine() is "1" then
  490.   if WaitForDataCon() then
  491.     if xType is "M" then FTPMacBinXfer dataID, "receive" -- MacBinary
  492.     else if xType is "H" then FTPhqXfer dataID, "receive" -- BinHex
  493.     else FTPxfer dataID, "receive", xType, localFile -- ASCII or Bin
  494.     put the result into xferResult
  495.  
  496.     if char 1 of xferResult is "┬º"
  497.     then
  498.     answer xferResult -- must be important
  499.     sendABOR -- send abort command to the host
  500.   else if fileMemory is "memory"
  501.   then showText remoteName, xferResult -- display the file
  502. end if
  503. end if
  504.  
  505. closeData  -- close data port
  506. end receiveFile
  507.  
  508. -- Transfer a file to the host
  509. on sendFile fileMemory, remName, sendText
  510.   global dataID
  511.  
  512.   if fileMemory is "memory" then
  513.     put "A" into xType
  514.     put empty into localName
  515.   else -- fileMemory is "file"
  516.     put xferType() into xType
  517.     if xType is "A" -- ASCII transfer?
  518.     then put FileName( "TEXT" ) into localName -- show only TEXT files
  519.   else put FileName()         into localName -- show all files
  520.   if localName is empty then exit sendFile
  521.  
  522.   put Translate( " ;|\,/{}[]<>!@#$%^&*()~`+='" & quote, "_", LeafName( localName ) ) into remName -- remove path & weird chars
  523.  
  524.   if xType is "M" then put ".bin" after remName
  525.   else if xType is "H" then put ".hqx" after remName
  526. end if
  527.  
  528. ask "Name to save as on the host:" with remName
  529. if it is empty then exit sendFile
  530. put it into remName
  531.  
  532. openData xType -- open data port using selected xfer type
  533. sendLine "STOR" && remName
  534.  
  535. if char 1 of getLine() is not "1" then
  536.   closeData -- just close the data port
  537.  
  538. else
  539.   if WaitForDataCon() then
  540.     if xType is "M" -- MacBinary?
  541.     then FTPMacBinXfer dataID, "send", localName
  542.   else if xType is "H" -- BinHex?
  543.   then FTPhqXfer dataID, "send", localName
  544. else FTPxfer dataID, "send", xType, localName, sendText
  545.  
  546. if char 1 of the result is "┬º" -- an error?
  547. then answer the result
  548.  
  549. closeData -- close the data port
  550. if char 1 of getLine() is "2" then getDir -- refresh the Dir List
  551. end if
  552. end if
  553. end sendFile
  554.  
  555. -- Change to the parent directory on the host.
  556. -- Some FTP servers use CDUP and others use XCUP so try them both.
  557. -- If neither works then try ΓÇÿCWD ..ΓÇÖ
  558. on cdup
  559.   global CDUPcmd
  560.  
  561.   if CDUPcmd is empty then put "CDUP" into CDUPcmd -- first try "CDUP"
  562.  
  563.   repeat 3 times
  564.     sendLine CDUPcmd -- change to parent directory
  565.     if char 1 of getLine() is "2" then -- did it work?
  566.       getDir -- update Entries and Path fields
  567.       exit repeat
  568.     end if
  569.  
  570.     -- didn't work so try the other commands
  571.     if CDUPcmd is "CDUP" then put "XCUP" into CDUPcmd
  572.     else if CDUPcmd is "XCUP" then put "CWD .." into CDUPcmd
  573.     else put "CDUP" into CDUPcmd
  574.   end repeat
  575. end cdup
  576.  
  577. -- Clicking the mouse in the bkgrd will deselect a Dir List entry:
  578. on mouseUp
  579.   global sLine
  580.   put zero into sLine
  581. end mouseUp
  582.  
  583. on diagMsg theMsg
  584.   global diagTxt, diagScroll
  585.  
  586.   get line one of theMsg
  587.   put it & return after diagTxt
  588.   put empty into diagScroll
  589.   put it into bg fld "Diag"
  590. end diagMsg
  591.  
  592. -- Pressing up/down arrows will select previous/next entry.
  593. -- Except that option-uparrow with perform a CDUP.
  594. on arrowKey whichKey
  595.   global sLine
  596.  
  597.   if whichKey is up and ( the optionKey is down or sLine is zero ) then
  598.     cdup -- change to the parent directory on the host
  599.     exit arrowKey
  600.   end if
  601.  
  602.   if sLine is not zero then -- any line selected?
  603.     if whichKey is up and sLine > 1 then subtract 1 from sLine
  604.     else if whichKey is down and sLine < the number of lines in bg fld "Dir List" then add 1 to sLine
  605.   end if
  606. end arrowKey
  607.  
  608. --  Pressing return is like clicking on the Connect button.
  609. on returnKey
  610.   autoConnect
  611. end returnKey
  612.  
  613. on autoConnect
  614.   if the short name of bg btn id 29 is "Connect" then
  615.     set the hilite of bg btn id 29 to true
  616.     wait 15 ticks
  617.     set the hilite of bg btn id 29 to false
  618.     send "connect" to bg btn id 29
  619.   end if
  620. end autoConnect
  621.  
  622. -- dirZoom is called by the Directory list 'zoom' box buttons.
  623. on dirZoom inOut -- inOut is "in" or "out"
  624.   set the icon of the target to "Zoom Box Star"
  625.  
  626.   repeat while the mouse is down
  627.     if the mouseLoc is within the rect of the target
  628.     then set the icon of the target to "Zoom Box Star"
  629.   else set the icon of the target to "Zoom Box"
  630. end repeat
  631.  
  632. set the icon of the target to "Zoom Box" -- reset icon on mouseUp
  633. if the mouseLoc is not within the rect of the target then exit dirZoom
  634.  
  635. put ( inOut = "out" ) into fullDisp
  636. if bg fld "Full Dir" is empty and fullDisp is true then readDir "long"
  637.  
  638. lock screen
  639. set the visible of bg fld "Full Dir" to fullDisp
  640. set the visible of bg btn "Zoom In"  to fullDisp
  641.  
  642. if fullDisp then
  643.   set the scroll of bg fld "Full Dir" to the scroll of bg fld "Dir List"
  644.   unlock screen with visual iris open fast
  645. else
  646.   set the scroll of bg fld "Dir List" to the scroll of bg fld "Full Dir"
  647.   unlock screen with visual iris close fast
  648. end if
  649. end dirZoom
  650.  
  651. -- Take care of a click on a line.  Select it if it's the first click.
  652. -- If the second click either change to it if it's a directory
  653. -- or retrieve it if it's a file.
  654. on lineClick
  655.   global sLine
  656.  
  657.   get ( ( the clickV - top of the target + scroll of the target ) div textHeight of the target ) + 1
  658.  
  659.   if it = sLine then getFile -- a double-click
  660.   else
  661.     if it > the number of lines of the value of the target then get zero
  662.     put it into sLine -- single-click: just select the line
  663.   end if
  664. end lineClick
  665.  
  666. -- Receive a file or change to a directory:
  667. -- (called by lineClick or by pressing return in a field)
  668. on getFile
  669.   global sLine
  670.  
  671.   get line sLine of bg fld "Dir List"
  672.   if not changeDir( it ) then receiveFile it, "receive"
  673. end getFile
  674.  
  675. -- The FTP XCMDs generate FTPprogress messages every 10K bytes or so.
  676. on FTPprogress bytes
  677.   set cursor to busy
  678.   put "Bytes transferred:" && bytes into bg fld "Diag"
  679. end FTPprogress
  680.  
  681. -- The FTP XCMDs generate an FTPrate message at the end of a transfer.
  682. -- For HC1.2, FTPMacBinXfer and FTPhqXfer set the global stdOpnTicks.
  683. on FTPrate bytes, elapTicks
  684.   global stdOpnTicks
  685.  
  686.   if stdOpnTicks is not empty then subtract stdOpnTicks from elapTicks
  687.   put elapTicks / 60 into elapSecs
  688.   if elapSecs is zero then leave FTPrate
  689.  
  690.   put numberFormat into numFormat
  691.   set numberFormat to "0.#"
  692.   diagMsg bytes && "bytes in" && elapSecs && "seconds =" && bytes / elapSecs && "bytes per second"
  693.   set numberFormat to numFormat
  694.   put empty into stdOpnTicks
  695. end FTPrate
  696.  
  697.  
  698. -- part 45 (field)
  699. -- low flags: 01
  700. -- high flags: 0002
  701. -- rect: left=13 top=320 right=334 bottom=484
  702. -- title width / last selected line: 0
  703. -- icon id / first selected line: 0 / 0
  704. -- text alignment: 0
  705. -- font id: 3
  706. -- text size: 9
  707. -- style flags: 0
  708. -- line height: 12
  709. -- part name: Diag
  710.  
  711.  
  712. -- part 29 (button)
  713. -- low flags: 00
  714. -- high flags: A003
  715. -- rect: left=345 top=18 right=47 bottom=438
  716. -- title width / last selected line: 0
  717. -- icon id / first selected line: 0 / 0
  718. -- text alignment: 1
  719. -- font id: 0
  720. -- text size: 12
  721. -- style flags: 0
  722. -- line height: 16
  723. -- part name: Connect
  724. ----- HyperTalk script -----
  725. -- this button can have one of two names and is set by the bg script
  726. on mouseUp
  727.   do the short name of me -- "connect" or "disconnect"
  728. end mouseUp
  729.  
  730. -- establish a connection with a host
  731. on connect
  732.   global connID
  733.  
  734.   if bg fld "Host Name" is empty then
  735.     diagMsg "Please enter a host name or address"
  736.     exit connect
  737.   end if
  738.  
  739.   diagMsg "Finding the address for host ΓÇÿ" & bg fld "Host Name" & "ΓÇÖ"
  740.   set cursor to busy -- this may take a whileΓǪ
  741.   get TCPNameToAddr( bg fld "Host Name" )
  742.  
  743.   if char 1 of it is "┬º" then
  744.     if it contains "couldn't open resource"
  745.     then diagMsg "MacTCPΓäó has not been installed."
  746.   else diagMsg "Can't get the IP address for ΓÇÿ" & bg fld "Host Name" & "ΓÇÖ"
  747.   exit connect
  748. end if
  749.  
  750. diagMsg "Opening FTP connection"
  751. put TCPActiveOpen( item 1 of it, 21, 0 ) into connID -- 21 = ftp
  752.  
  753. if connID contains "fail" then
  754.   diagMsg connID
  755.   put empty into connID
  756. end if
  757. end connect
  758.  
  759. -- Close the communication connection
  760. on disconnect
  761.   global connID
  762.  
  763.   if bg fld "State" is "established" then
  764.     sendLine "QUIT" -- be nice and send a quit cmd to the host
  765.     if getLine() is not empty then exit disconnect -- wait for close
  766.   end if
  767.  
  768.   TCPClose connID -- something must be wrong so just close it
  769. end disconnect
  770.  
  771.  
  772.  
  773. -- part 37 (field)
  774. -- low flags: 01
  775. -- high flags: 0004
  776. -- rect: left=148 top=35 right=55 bottom=307
  777. -- title width / last selected line: 0
  778. -- icon id / first selected line: 0 / 0
  779. -- text alignment: 0
  780. -- font id: 2
  781. -- text size: 12
  782. -- style flags: 512
  783. -- line height: 16
  784. -- part name: State
  785.  
  786.  
  787. -- part 53 (field)
  788. -- low flags: 00
  789. -- high flags: 0002
  790. -- rect: left=54 top=12 right=30 bottom=305
  791. -- title width / last selected line: 0
  792. -- icon id / first selected line: 0 / 0
  793. -- text alignment: 0
  794. -- font id: 3
  795. -- text size: 12
  796. -- style flags: 0
  797. -- line height: 16
  798. -- part name: Host Name
  799. ----- HyperTalk script -----
  800. -- Make pressing return or enter in the Host Name field
  801. -- automatically connect to the host.
  802. -- It also prevents return chars from getting into the field text.
  803.  
  804. on returnInField
  805.   autoConnect -- send msg to background
  806. end returnInField
  807.  
  808. on enterInField
  809.   autoConnect -- send msg to background
  810. end enterInField
  811.  
  812.  
  813. -- part 54 (button)
  814. -- low flags: 00
  815. -- high flags: A002
  816. -- rect: left=387 top=111 right=127 bottom=485
  817. -- title width / last selected line: 0
  818. -- icon id / first selected line: 0 / 0
  819. -- text alignment: 1
  820. -- font id: 111
  821. -- text size: 12
  822. -- style flags: 0
  823. -- line height: 16
  824. -- part name: Send╔
  825. ----- HyperTalk script -----
  826. on mouseUp
  827.   sendFile "file" -- send message to background handler
  828. end mouseUp
  829.  
  830.  
  831.  
  832. -- part 62 (button)
  833. -- low flags: 00
  834. -- high flags: A002
  835. -- rect: left=387 top=202 right=218 bottom=471
  836. -- title width / last selected line: 0
  837. -- icon id / first selected line: 0 / 0
  838. -- text alignment: 1
  839. -- font id: 111
  840. -- text size: 12
  841. -- style flags: 0
  842. -- line height: 16
  843. -- part name: Set╔
  844. ----- HyperTalk script -----
  845. -- Set the current directory on the host.
  846. on mouseUp
  847.   global sLine
  848.  
  849.   if sLine is not zero and the optionKey is up then
  850.     get line sLine of bg fld "Dir List" -- use selected entry name
  851.   else
  852.     ask "Change directory to:" with bg fld "Path" -- else prompt w/ path
  853.     if it is empty then exit mouseUp
  854.   end if
  855.  
  856.   get changeDir( it ) -- send message to background script
  857. end mouseUp
  858.  
  859.  
  860.  
  861. -- part 64 (field)
  862. -- low flags: 01
  863. -- high flags: 0004
  864. -- rect: left=91 top=75 right=95 bottom=492
  865. -- title width / last selected line: 0
  866. -- icon id / first selected line: 0 / 0
  867. -- text alignment: 0
  868. -- font id: 3
  869. -- text size: 12
  870. -- style flags: 512
  871. -- line height: 16
  872. -- part name: Path
  873. ----- HyperTalk script -----
  874. -- Update Entries and Directory fields.
  875. -- It should not be necessary to do but it can come in handy sometimes.
  876. on mouseUp
  877.   global connID
  878.  
  879.   if connID is not empty then -- must be connected to a host
  880.     put empty into bg fld "Path"
  881.     put empty into bg fld "Dir List"
  882.     getDir -- request new dir info from the host
  883.   end if
  884. end mouseUp
  885.  
  886.  
  887.  
  888. -- part 66 (button)
  889. -- low flags: 00
  890. -- high flags: A002
  891. -- rect: left=387 top=129 right=145 bottom=485
  892. -- title width / last selected line: 0
  893. -- icon id / first selected line: 0 / 0
  894. -- text alignment: 1
  895. -- font id: 111
  896. -- text size: 12
  897. -- style flags: 0
  898. -- line height: 16
  899. -- part name: Receive╔
  900. ----- HyperTalk script -----
  901. on mouseUp
  902.   global sLine
  903.  
  904.   if sLine is not zero
  905.   then put line sLine of bg fld "Dir List" into remoteName
  906. else put empty into remoteName
  907.  
  908. if the optionKey is down then
  909.   ask "Name of the file to receive:" with remoteName
  910.   if it is empty then exit mouseUp
  911.   put it into remoteName
  912. end if
  913.  
  914. if remoteName is empty then
  915.   beep
  916.   exit mouseUp
  917. end if
  918.  
  919. receiveFile remoteName, "file" -- call bg script
  920. end mouseUp
  921.  
  922.  
  923.  
  924. -- part 67 (button)
  925. -- low flags: 00
  926. -- high flags: 0000
  927. -- rect: left=463 top=12 right=30 bottom=481
  928. -- title width / last selected line: 0
  929. -- icon id / first selected line: 26635 / 26635
  930. -- text alignment: 1
  931. -- font id: 0
  932. -- text size: 12
  933. -- style flags: 0
  934. -- line height: 16
  935. -- part name: Help
  936. ----- HyperTalk script -----
  937. on mouseUp
  938.   global showFullDir
  939.  
  940.   lock screen
  941.   get the hilite of me
  942.   set the hilight of me to not it
  943.  
  944.   if it is true then
  945.     set the visible of bg fld "Full Dir" to showFullDir
  946.     set the visible of bg btn "Zoom In"  to showFullDir
  947.     put empty into showFullDir
  948.     go card "Main"
  949.   else
  950.     put the visible of bg fld "Full Dir" into showFullDir
  951.     set the visible of bg fld "Full Dir" to false
  952.     set the visible of bg btn "Zoom In"  to false
  953.     go card "Info"
  954.   end if
  955.  
  956.   unlock screen with visual effect dissolve fast
  957. end mouseUp
  958.  
  959.  
  960.  
  961. -- part 71 (button)
  962. -- low flags: 00
  963. -- high flags: 0004
  964. -- rect: left=307 top=12 right=30 bottom=327
  965. -- title width / last selected line: 0
  966. -- icon id / first selected line: 11893 / 11893
  967. -- text alignment: 1
  968. -- font id: 0
  969. -- text size: 12
  970. -- style flags: 0
  971. -- line height: 16
  972. -- part name: Host List
  973. ----- HyperTalk script -----
  974. -- Display the Host List pop-up menu.
  975. -- Select an entry and it will be put into the Host Name field and
  976. -- the Connect button will be pressed.  Select Edit Host List from the
  977. -- menu to modify the menu contents.
  978.  
  979. on mouseDown
  980.   put bg fld "Host Name" into HostName
  981.   if HostName is not empty
  982.   then put "!" & NumToChar(18) & HostName & ";-;" into HostName
  983.   put cd fld "Host List" of card "Host List" into HostList
  984.   put HostList into xHostList
  985.   if HostList is not empty then put ";-;" after xHostList
  986.  
  987.   get PopUpMenu( HostName & xHostList & "<IEdit Host ListΓǪ", empty, left of card window + left of me + 1, top  of card window + top  of me + 1 )
  988.  
  989.   if it is empty then exit mouseDown -- no menu item was chosen
  990.   if HostName is not empty then subtract 2 from it
  991.   if it < 1 then get bg fld "Host Name"
  992.   else get word 1 of line it of HostList -- get the host name
  993.  
  994.   if it is empty then -- edit host list?
  995.     visual effect iris open fast
  996.     go card "Host List"
  997.   else
  998.     if the short name of bg btn id 29 is "Disconnect" then
  999.       beep
  1000.       answer "Disconnect before choosing another host"
  1001.     else
  1002.       put it into bg fld "Host Name"
  1003.       if the optionKey is not down then autoConnect
  1004.     end if
  1005.   end if
  1006. end mouseDown
  1007.  
  1008. on mouseUp
  1009.   -- don't send mouseUp to bg
  1010. end mouseUp
  1011.  
  1012.  
  1013.  
  1014. -- part 74 (button)
  1015. -- low flags: 00
  1016. -- high flags: 2000
  1017. -- rect: left=460 top=33 right=53 bottom=485
  1018. -- title width / last selected line: 0
  1019. -- icon id / first selected line: 21700 / 21700
  1020. -- text alignment: 1
  1021. -- font id: 0
  1022. -- text size: 12
  1023. -- style flags: 0
  1024. -- line height: 16
  1025. -- part name: Home
  1026. ----- HyperTalk script -----
  1027. on mouseUp
  1028.   go home
  1029. end mouseUp
  1030.  
  1031.  
  1032.  
  1033. -- part 75 (button)
  1034. -- low flags: 00
  1035. -- high flags: 2000
  1036. -- rect: left=473 top=204 right=218 bottom=487
  1037. -- title width / last selected line: 0
  1038. -- icon id / first selected line: 21012 / 21012
  1039. -- text alignment: 1
  1040. -- font id: 0
  1041. -- text size: 12
  1042. -- style flags: 0
  1043. -- line height: 16
  1044. -- part name: Parent Dir
  1045. ----- HyperTalk script -----
  1046. -- Change to the parent directory on the host.
  1047. on mouseUp
  1048.   cdup -- send msg to bkg script
  1049. end mouseUp
  1050.  
  1051.  
  1052.  
  1053. -- part 76 (button)
  1054. -- low flags: 00
  1055. -- high flags: A002
  1056. -- rect: left=387 top=147 right=163 bottom=485
  1057. -- title width / last selected line: 0
  1058. -- icon id / first selected line: 0 / 0
  1059. -- text alignment: 1
  1060. -- font id: 111
  1061. -- text size: 12
  1062. -- style flags: 0
  1063. -- line height: 16
  1064. -- part name: Display
  1065. ----- HyperTalk script -----
  1066. on mouseUp
  1067.   global sLine
  1068.  
  1069.   if sLine is not zero
  1070.   then put line sLine of bg fld "Dir List" into remoteName
  1071. else put empty into remoteName
  1072.  
  1073. if the optionKey is down then
  1074.   ask "Name of the file to display:" with remoteName
  1075.   if it is empty then exit mouseUp
  1076.   put it into remoteName
  1077. end if
  1078.  
  1079. if remoteName is empty then
  1080.   beep
  1081.   exit mouseUp
  1082. end if
  1083.  
  1084. receiveFile remoteName, "memory" -- call bg script
  1085. end mouseUp
  1086.  
  1087.  
  1088.  
  1089. -- part 77 (button)
  1090. -- low flags: 00
  1091. -- high flags: A002
  1092. -- rect: left=387 top=165 right=181 bottom=485
  1093. -- title width / last selected line: 0
  1094. -- icon id / first selected line: 0 / 0
  1095. -- text alignment: 1
  1096. -- font id: 111
  1097. -- text size: 12
  1098. -- style flags: 0
  1099. -- line height: 16
  1100. -- part name: Delete
  1101. ----- HyperTalk script -----
  1102. -- Delete a file or directory from the host:
  1103. on mouseUp
  1104.   global sLine
  1105.  
  1106.   if sLine is not zero
  1107.   then put line sLine of bg fld "Dir List" into remoteName
  1108. else put empty into remoteName
  1109.  
  1110. if the optionKey is down then
  1111.   ask "Name of the file to delete:" with remoteName
  1112.   if it is empty then exit mouseUp
  1113.   put it into remoteName
  1114. end if
  1115.  
  1116. if remoteName is empty then
  1117.   beep
  1118.   exit mouseUp
  1119. end if
  1120.  
  1121. answer "Really delete ΓÇÿ" & remoteName & "ΓÇÖ?" with "Delete" or "Cancel"
  1122. if it is "Delete" then
  1123.   sendLine "DELE" && remoteName
  1124.   if char 1 of getLine() is "2" then getDir -- refresh the dir list
  1125. end if
  1126. end mouseUp
  1127.  
  1128.  
  1129.  
  1130. -- part 78 (button)
  1131. -- low flags: 00
  1132. -- high flags: A002
  1133. -- rect: left=387 top=220 right=236 bottom=485
  1134. -- title width / last selected line: 0
  1135. -- icon id / first selected line: 0 / 0
  1136. -- text alignment: 1
  1137. -- font id: 111
  1138. -- text size: 12
  1139. -- style flags: 0
  1140. -- line height: 16
  1141. -- part name: Create╔
  1142. ----- HyperTalk script -----
  1143. -- Create a new directory on the host.
  1144. -- Some FTP servers use MKD and others use XMKD so try them both.
  1145.  
  1146. on mouseUp
  1147.   global MKDcmd
  1148.  
  1149.   ask "New directory name:"
  1150.   if it is empty then exit mouseUp
  1151.   put it into newDir
  1152.  
  1153.   if MKDcmd is empty then put "MKD" into MKDcmd -- first try "MKD"
  1154.  
  1155.   repeat 2 times
  1156.     sendLine MKDcmd && newDir -- create the directory
  1157.     if char 1 of getLine() is "2" then -- did it work?
  1158.       get changeDir( newDir ) -- change to the new dir
  1159.       exit repeat
  1160.     end if
  1161.  
  1162.     if MKDcmd is "MKD" -- didn't work so try the other command
  1163.     then put "XMKD" into MKDcmd
  1164.   else put "MKD"  into MKDcmd
  1165. end repeat
  1166. end mouseUp
  1167.  
  1168.  
  1169.  
  1170. -- part 73 (button)
  1171. -- low flags: 00
  1172. -- high flags: 0000
  1173. -- rect: left=381 top=105 right=240 bottom=491
  1174. -- title width / last selected line: 0
  1175. -- icon id / first selected line: 0 / 0
  1176. -- text alignment: 1
  1177. -- font id: 0
  1178. -- text size: 12
  1179. -- style flags: 0
  1180. -- line height: 16
  1181. -- part name: Hide Xfers
  1182. ----- HyperTalk script -----
  1183. -- this button is made visible while there is no connection
  1184. -- in order to disable the buttons underneath it.
  1185. on mouseUp
  1186.   diagMsg "First enter a host name and press the Connect button"
  1187.   beep
  1188. end mouseUp
  1189.  
  1190.  
  1191.  
  1192. -- part 79 (field)
  1193. -- low flags: 03
  1194. -- high flags: 0007
  1195. -- rect: left=91 top=104 right=288 bottom=371
  1196. -- title width / last selected line: 0
  1197. -- icon id / first selected line: 0 / 0
  1198. -- text alignment: 0
  1199. -- font id: 3
  1200. -- text size: 12
  1201. -- style flags: 0
  1202. -- line height: 14
  1203. -- part name: Dir List
  1204. ----- HyperTalk script -----
  1205. -- Take care of a click on a line.  Select it if it's the first click.
  1206. -- If the second click either change to it if it's a directory
  1207. -- or retrieve it if it's a file.
  1208. on mouseUp
  1209.   lineClick
  1210. end mouseUp
  1211.  
  1212. -- Pressing the Return key is just like double-clicking on an Entry
  1213. on returnInField
  1214.   getFile
  1215. end returnInField
  1216.  
  1217.  
  1218.  
  1219. -- part 80 (field)
  1220. -- low flags: 01
  1221. -- high flags: 0002
  1222. -- rect: left=387 top=262 right=280 bottom=478
  1223. -- title width / last selected line: 0
  1224. -- icon id / first selected line: 0 / 0
  1225. -- text alignment: 0
  1226. -- font id: 0
  1227. -- text size: 12
  1228. -- style flags: 0
  1229. -- line height: 16
  1230. -- part name: Mode
  1231. ----- HyperTalk script -----
  1232. -- Display a pop-up menu when the Mode field is selected.
  1233.  
  1234. on mouseDown
  1235.   put "ASCII,Binary,MacBinary,BinHex" into menuItems
  1236.   if me is "ASCII" then put 1 into curItem
  1237.   else if me is "Binary" then put 2 into curItem
  1238.   else if me is "MacBinary" then put 3 into curItem
  1239.   else put 4 into curItem -- must be BinHex
  1240.  
  1241.   get PopUpMenu( menuItems, curItem, left of card window + left of me + 1, top of card window + top of me + 1 ) -- display the pop-up menu
  1242.  
  1243.   if it is empty then exit mouseDown -- nothing was selected
  1244.  
  1245.   put item it of menuItems into me -- replace the contents of the field
  1246. end mouseDown
  1247.  
  1248. on mouseUp
  1249.   -- don't pass mouseUp to bg script
  1250. end mouseUp
  1251.  
  1252.  
  1253. -- part 81 (button)
  1254. -- low flags: 00
  1255. -- high flags: 0002
  1256. -- rect: left=341 top=106 right=118 bottom=353
  1257. -- title width / last selected line: 0
  1258. -- icon id / first selected line: 9018 / 9018
  1259. -- text alignment: 1
  1260. -- font id: 0
  1261. -- text size: 12
  1262. -- style flags: 0
  1263. -- line height: 16
  1264. -- part name: Zoom Out
  1265. ----- HyperTalk script -----
  1266. on mouseDown
  1267.   if bg fld "State" is not "established" then exit mouseDown
  1268.   dirZoom "out"
  1269. end mouseDown
  1270.  
  1271. on mouseUp
  1272. end mouseUp
  1273.  
  1274.  
  1275. -- part 83 (field)
  1276. -- low flags: 81
  1277. -- high flags: 0007
  1278. -- rect: left=11 top=104 right=288 bottom=497
  1279. -- title width / last selected line: 0
  1280. -- icon id / first selected line: 0 / 0
  1281. -- text alignment: 0
  1282. -- font id: 4
  1283. -- text size: 9
  1284. -- style flags: 0
  1285. -- line height: 14
  1286. -- part name: Full Dir
  1287. ----- HyperTalk script -----
  1288. -- Take care of a click on a line.  Select it if it's the first click.
  1289. -- If the second click either change to it if it's a directory
  1290. -- or retrieve it if it's a file.
  1291. on mouseUp
  1292.   lineClick
  1293. end mouseUp
  1294.  
  1295. -- Pressing the Return key is just like double-clicking on an Entry
  1296. on returnInField
  1297.   getFile
  1298. end returnInField
  1299.  
  1300.  
  1301.  
  1302. -- part 82 (button)
  1303. -- low flags: 80
  1304. -- high flags: 0002
  1305. -- rect: left=467 top=106 right=118 bottom=479
  1306. -- title width / last selected line: 0
  1307. -- icon id / first selected line: 9018 / 9018
  1308. -- text alignment: 1
  1309. -- font id: 0
  1310. -- text size: 12
  1311. -- style flags: 0
  1312. -- line height: 16
  1313. -- part name: Zoom In
  1314. ----- HyperTalk script -----
  1315. on mouseDown
  1316.   dirZoom "in"
  1317. end mouseDown
  1318.  
  1319. on mouseUp
  1320. end mouseUp
  1321.  
  1322.  
  1323. -- part 84 (button)
  1324. -- low flags: 00
  1325. -- high flags: 2000
  1326. -- rect: left=486 top=311 right=323 bottom=498
  1327. -- title width / last selected line: 0
  1328. -- icon id / first selected line: 0 / 0
  1329. -- text alignment: 1
  1330. -- font id: 0
  1331. -- text size: 12
  1332. -- style flags: 0
  1333. -- line height: 16
  1334. -- part name: Diag Up
  1335. ----- HyperTalk script -----
  1336. -- Scroll up through the recent diagnostic lines
  1337. on mouseDown
  1338.   global diagTxt, diagScroll
  1339.  
  1340.   if diagScroll is empty
  1341.   then put the number of lines in diagTxt into diagScroll
  1342.   put zero into time2scroll -- scroll once right away
  1343.   put 45 into scInterval -- first scroll interval
  1344.  
  1345.   repeat while diagScroll > one
  1346.     get the ticks
  1347.     if it ΓëÑ time2scroll then
  1348.       put it + scInterval into time2scroll -- set next time to scroll
  1349.       put 15 into scInterval -- set scroll interval from now on
  1350.       subtract one from diagScroll
  1351.       put line diagScroll of diagTxt into bg fld "Diag"
  1352.     end if
  1353.  
  1354.     if the mouse is up then exit repeat -- check mouse after loop
  1355.   end repeat
  1356. end mouseDown
  1357.  
  1358. on mouseUp
  1359.   -- don't pass mouseUp msg
  1360. end mouseUp
  1361.  
  1362.  
  1363. -- part 85 (button)
  1364. -- low flags: 00
  1365. -- high flags: 2000
  1366. -- rect: left=486 top=322 right=334 bottom=498
  1367. -- title width / last selected line: 0
  1368. -- icon id / first selected line: 0 / 0
  1369. -- text alignment: 1
  1370. -- font id: 0
  1371. -- text size: 12
  1372. -- style flags: 0
  1373. -- line height: 16
  1374. -- part name: Diag Down
  1375. ----- HyperTalk script -----
  1376. -- Scroll down through the recent diagnostic lines
  1377. on mouseDown
  1378.   global diagTxt, diagScroll
  1379.  
  1380.   put the number of lines in diagTxt into numLines
  1381.   if diagScroll is empty then put numLines into diagScroll
  1382.   put zero into time2scroll -- scroll once right away
  1383.   put 45 into scInterval -- first scroll interval
  1384.  
  1385.   repeat while diagScroll < numLines
  1386.     get the ticks
  1387.     if it ΓëÑ time2scroll then
  1388.       put it + scInterval into time2scroll -- set next time to scroll
  1389.       put 15 into scInterval -- set scroll interval from now on
  1390.       add one to diagScroll
  1391.       put line diagScroll of diagTxt into bg fld "Diag"
  1392.     end if
  1393.  
  1394.     if the mouse is up then exit repeat -- check mouse after loop
  1395.   end repeat
  1396. end mouseDown
  1397.  
  1398. on mouseUp
  1399.   -- don't pass mouseUp msg
  1400. end mouseUp
  1401.