# charset="CP932" # encode="CP932" # SETI_stat3 for System 7.5.5 #! MacPerl -w require 'FindFolder.pl'; $workdir = MacPerl::FindFolder('Preferences') . 'SETI@home Data:'; $workdir = MacPerl::FindFolder('System') . 'Application Support:SETI@home Data:' unless -e $workdir; $workdir = MacPerl::FindFolder('System') . 'アプリケーションサポート:SETI@home Data:' unless -e $workdir; die 'error has occured. may be I cannot find folder "SETI@home Data".' unless -e $workdir; ($workfile, $finish) = ($workdir . 'work_unit.sah', 0); ($workfile, $finish) = ($workdir . 'wtemp.sah', 1) unless -e $workfile; die 'error has occured. may be I cannot find work unit file.' unless -e $workfile; $statusfile = $workdir . 'state.sah'; die 'error has occured. may be I cannot find "state.sah".' unless -e $statusfile; $/ = "\012"; open(WF, $workfile) || die 'error has occured. may be I cannot read work unit data.'; open(SF, $statusfile) || die 'error has occured. may be I cannot read state data.'; chomp(@rresult = (()[4,3], ()[$finish ? (15, 16, 20) : (8, 9, 13)])); close WF; close SF; $\ = $, = "\n"; print '@ ' . scalar localtime, @rresult, 'estimate=' . ( (split /= ?/, $rresult[1])[-1] / (split /= ?/, $rresult[0])[-1] / 3600 ) . 'h', '.'; __END__ (* AppleScript *) -- ver 3.00 初版 -- (* System 7 對應版 by hanaden *) tell application "Finder" if version is not less than 10 then -- version is greater than or equal to 10 error number -128 else if version < 9 then preferences folder else if version contains "J" then system folder's folder "アプリケーションサポート" -- as Unicode text else system folder's folder "Application Support" end if set workdir to result's folder "SETI@home Data" tell workdir set finish to false try file "work_unit.sah" on error -- no work_unit.sah set finish to true file "wtemp.sah" end try copy result as alias to workfile file "state.sah" copy result as alias to statusfile end tell end tell set text item delimiters to ASCII character 10 try open for access workfile without write permission returning WF read WF for 500 copy result's text items as list to target close access WF on error display dialog "error has occured. may be I cannot read work unit data." buttons "cancel" with icon caution end try tell target if not finish then {item 9, item 10, item 14} else {item 16, item 17, item 21} end if set {RA, DEC, RTIME} to result end tell try open for access statusfile without write permission returning SF read SF copy result's text items as list to target close access SF on error display dialog "error has occured. may be I cannot read state data." buttons "cancel" with icon caution end try tell target set {PROGRESS, CPUTIME} to {item 5, item 4} end tell set text item delimiters to return set Rresult to {PROGRESS, CPUTIME, RA, DEC, RTIME, "estimate =" & ((CPUTIME's word 3) / (PROGRESS's word 3) / 3600) & "h"} as text set text item delimiters to "" -- (* initialize *) try path to desktop as text result & "SETI@home Statistics" open for access file result with write permission returning LF current date result as text "@ " & result & return & Rresult & return & "." & return write result to LF starting at eof close access LF on error display dialog Rresult with icon note end try