home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Comms Spectacular / 5PM / Palettes Folder / Power-Users folder / 5PM Script < prev    next >
Encoding:
Text File  |  1992-09-22  |  4.5 KB  |  139 lines  |  [TEXT/ttxt]

  1.  
  2.  ----------------------------------------------------------------------------------
  3.  -- Some 5PM hidden features :
  4.  --     Control-Option in the Settings menu makes appear the Tools Scripting Interface Dlogs
  5.  --     Shift-Option in the Settings menu makes appear the TermKeys Dlog (Term Tools only)
  6.  --
  7.  -- Some short-cuts when editing palettes :
  8.  --     Tab key checks and reformats the script
  9.  --     Enter key saves and closes the script
  10.  --     Shift-double-click on a button makes appear directly its script
  11.  --     Option-Shift-double-click on a button makes appear directly the Font Dlog
  12.  ----------------------------------------------------------------------------------
  13.  On startup
  14. -- this script starts when launching the application
  15.  End startup
  16.  
  17.  
  18.  ----------------------------------------------------------------------------------
  19.  --
  20.  ----------------------------------------------------------------------------------
  21.  Function GetCommandOutPut cmd, timeOut
  22.     Global glob_Session
  23.  
  24.     Transmit cmd & " ; echo ***\***" & cr in glob_Session
  25.     CollectFrom session glob_Session until "******", timeOut
  26.  
  27.     Return it
  28.  End GetCommandOutPut
  29.  
  30.  
  31.  ----------------------------------------------------------------------------------
  32.  --
  33.  ----------------------------------------------------------------------------------
  34.  On GetCurrDir
  35.     Global glob_CurrDir
  36.     Global glob_DirSize
  37.     Global glob_Session
  38.     Global glob_FileList
  39.     Global glob_NbrOfFiles
  40.     Global glob_StartFile
  41.  
  42.     Set the cursor of 5PM to 4
  43.  
  44.     Get GetCommandOutPut ("/bin/ls -la", 1000)
  45.     If it is not empty then
  46.        Put it into glob_FileList
  47.     End If
  48.  
  49.     Put word 2 of line 2 of glob_FileList into glob_DirSize
  50.     Set the name of button 32577 in palt "LS" to glob_DirSize
  51.  
  52.     Put the number of lines in glob_FileList - 3 into glob_NbrOfFiles
  53.     Set the name of button 30967 in palt "LS" to glob_NbrOfFiles
  54.  
  55.     Get GetCommandOutPut ("pwd", 1000)
  56.     Put line 2 of it into glob_CurrDir
  57.     Put char 2 to 99 of glob_CurrDir into glob_CurrDir
  58.     Set the name of button 20030 in palt "LS" to glob_CurrDir
  59.     Put 1 into glob_StartFile
  60.  End GetCurrDir
  61.  
  62.  
  63.  ----------------------------------------------------------------------------------
  64.  --
  65.  ----------------------------------------------------------------------------------
  66.  On ListFile
  67.     Global glob_CurrDir
  68.     Global glob_FileList
  69.     Global glob_StartFile
  70.     Global glob_NbrOfFiles
  71.  
  72.     Open palette "LS"
  73.     Set the cursor of 5PM to 1000
  74.  
  75.     Set the lockScreen of palt "LS" to true
  76.     Put 0 into whichIcon
  77.     Put glob_StartFile + 24 into endFile
  78.     Repeat with whichFile = glob_StartFile to endFile
  79.        Add 1 to whichIcon
  80.        Put "button #" & whichIcon into aButton
  81.  
  82.        Get line whichFile + 2 of glob_FileList
  83.        If whichFile > glob_NbrOfFiles then
  84.           Set the visible of aButton in palt "LS" to false
  85.        Else
  86.           Put word 9 of it into fileName
  87.           Put word 1 of it into fileType
  88.           Set the name of aButton in palt "LS" to fileName
  89.           If char 2 of fileType is "d" then
  90.              Set the icon of aButton in palt "LS" to 30029
  91.           Else
  92.              If fileType contains "x" then
  93.                 Set the icon of aButton in palt "LS" to 30028
  94.              Else
  95.                 Set the icon of aButton in palt "LS" to 30030
  96.              End If
  97.           End If
  98.           Set the visible of aButton in palt "LS" to true
  99.        End If
  100.     End Repeat
  101.  
  102.     Set the lockScreen of palt "LS" to false
  103.     Set the cursor of 5PM to 0
  104.  End ListFile
  105.  
  106.  
  107.  ----------------------------------------------------------------------------------
  108.  -- This function will log in to AUX. Pass quiet in orderr to not receive
  109.  -- any warning or error messages on the screen.
  110.  ----------------------------------------------------------------------------------
  111.  Function AUXLogin userID, userPswd, quiet
  112.     Set the cursor of 5PM to 1000
  113.     DoMenu "Open Connection"
  114.  
  115.     Repeat while not isConnOpen ()
  116.     End Repeat
  117.  
  118.     Put matchString ("login:") into match
  119.     Put waitForMatch (360) into foundMatch
  120.     If foundMatch is not match then
  121.        If not quiet then
  122.           Answer "Did not manage to connect to AUX"
  123.        End If
  124.        Put false into areLoggedIn
  125.     Else
  126.        Transmit userID & cr
  127.  
  128.        Put matchString ("Password:") into match
  129.        Put waitForMatch (60) into foundMatch
  130.        If foundMatch is match then
  131.           Transmit userPswd & cr
  132.        End If
  133.        Put true into areLoggedIn
  134.     End If
  135.     Set the cursor of 5PM to 0
  136.  
  137.     Return areLoggedIn
  138.  End AUXLogin
  139.