home *** CD-ROM | disk | FTP | other *** search
EPOC OPL Source | 2000-10-05 | 10.2 KB | 387 lines |
-
-
- REM Macro SaveNews v1.00
-
- REM To be used with Macro5 (from v2.37)
- REM and RMRNews News Reader for EPOC (v1.00F English)
- REM by S.Alisi - sergioalisi@geocities.com
- REM http://www.geocities.com/siliconvalley/bridge/1492
-
- CONST AppName$="SaveNews"
- CONST AppVersion$=" v1.00"
- CONST DataUID&=&10000086
- CONST NewsUID&=&100004A1
- CONST IniFile$="C:\System\SaveNews.ini"
- CONST SourceBoxName$="SaveNews.box"
- CONST YesBtn$="Y" rem "Yes button" shortcut in RMRNews
-
- PROC Main:
- GLOBAL News$(255),Data$(255)
- GLOBAL NewsRSC$(255),DataRSC$(255)
- GLOBAL MultiBox%,UserDialog%,MacroNew%
- GLOBAL NumMsg&,NumMsg%,DelMsg%
- GLOBAL Date$(30),From$(250),Subject$(250),Body$(250)
-
- Macro5Test:
- Macro5Ver:
- NumMsg&=1 :NumMsg%=1
- if IniSetup%: :return :endif
- if StartNews%: :return :endif
- GetFocus:
- if MultiBox%
- if MultiBoxProc%:(1) :return :endif
- endif
- if UserDialog%
- if UserDialogProc%: :return :endif
- endif
- StartData:
- while NumMsg%<=NumMsg&
- if CopyFromNews%: :return :endif
- AdjustDate:
- PasteToData:
- Report:
- NumMsg%=NumMsg%+1
- endwh
- ENDP
-
- PROC Macro5Test:
- rem check if SaveNews is launched from Macro5 and as a macro
- onerr No_Macro::
- News$=GetApp$:(NewsUID&) rem for S5 & Geofox
- goto Yes_Macro::
- No_Macro::
- onerr off
- alert(AppName$+" Macro"+AppVersion$,"To be launched as a macro with Macro5")
- stop
- Yes_Macro::
- ENDP
-
- PROC Macro5Ver:
- rem check which version of Macro5 is currently installed
- onerr Old_Macro::
- if LibVersion%: >=240
- MacroNew%=-1
- endif
- goto Done::
- Old_Macro::
- onerr off
- MacroNew%=0
- stop
- Done::
- ENDP
-
- PROC IniSetup%:
- if News$=""
- alert(AppName$+" Macro"+AppVersion$,"Sorry, I can't find RMRNews.app")
- return -1
- endif
- NewsRSC$=Left$(News$,Len(News$)-3)+"rsc"
- if not exist (IniFile$)
- Data$="*"+Right$(SourceBoxName$,4)
- DataRSC$="Z:\System\Apps\Data\Data.rsc" rem for Psion S5
- if not exist (DataRSC$)
- DataRSC$="Z:\System\Apps\Data\Data.ruk" rem for Geofox
- if not exist (DataRSC$)
- alert(AppName$+" Macro"+AppVersion$,"Sorry, I can't find Data.rsc/ruk")
- return -1
- endif
- endif
- dinit AppName$+" Setup (step 1 of 3) ..."
- dtext "","- your RMRNews.app is located on drive """+Left$(News$,1)+""""
- if MacroNew%
- dtext "","- your Macro5 version is "+gen$(LibVersion%:/100,2)+"."+right$(gen$(LibVersion%:,4),2)
- else
- dtext "","- SaveNews is not tested with Macro5 versions prior to 2.37"
- endif
- dbuttons "Cancel",27,"Continue",13
- if dialog
- else
- alert(AppName$+" Setup aborted...","Relaunch the macro to complete")
- return -1
- endif
- if MultiBoxProc%:(0)
- alert(AppName$+" Setup aborted...","Relaunch the macro to complete")
- return -1
- endif
- dinit AppName$+" Setup (step 3 of 3)"
- dtext "","Each time you launch SaveNews you can ..."
- dcheckbox MultiBox%,"- have a choice of the target Data file"
- dtext "","- open a dialog window to automate the process"
- dcheckbox UserDialog%,"of archiving/deleting a group of articles"
- dbuttons "Cancel",27,"Continue",13
- if dialog
- else
- alert(AppName$+" Setup aborted...","Relaunch the macro to complete")
- return -1
- endif
- create IniFile$,a,Data$,DataRSC$,MultiBox%,UserDialog%
- a.Data$=Data$
- a.DataRSC$=DataRSC$
- a.MultiBox%=MultiBox%
- a.UserDialog%=UserDialog%
- append
- close
- alert(AppName$+" Setup successfully completed...","Now you can relaunch the macro")
- return -1
- else
- open IniFile$,a,Data$,DataRSC$,MultiBox%,UserDialog%
- Data$=a.Data$
- DataRSC$=a.DataRSC$
- MultiBox%=a.MultiBox%
- UserDialog%=a.UserDialog%
- close
- endif
- ENDP
-
- PROC StartNews%:
- if MacroNew% rem Macro5 v2.40 or later installed
- busy "Opening RMRNews, please wait ...",3,1
- if (FgApp%:(News$))=1
- busy off
- GetFocus:
- alert("SaveNews has opened your RMRNews program...","Now highlight an article header and relaunch")
- return -1
- endif
- busy off
- else rem Macro5 v2.37 installed
- if (FgApp%:(News$))=1
- GetFocus:
- giprint "Opening RMRNews, please wait..."
- pause 90
- alert("SaveNews is opening RMRNews program...","Highlight an article header and relaunch")
- return -1
- endif
- endif
- ENDP
-
- PROC StartData:
- if MacroNew%=0 rem Macro5 v2.37 installed
- if (FgApp%:(Data$))=1
- GetFocus:
- giprint "Opening NewsBox file, please wait..."
- pause 150
- endif
- FgApp%:(News$)
- endif
- ENDP
-
- PROC MultiBoxProc%:(Type%)
- LOCAL Button%,SetDefault%,SourceBox$(255)
- Startup::
- SourceBox$=Macros$+SourceBoxName$
- if Type%=1 rem call from Main: procedure
- dinit AppName$+AppVersion$
- dtext "","Select the location of your target Data file:"
- else rem call from IniSetup%: procedure
- dinit AppName$+" Setup (step 2 of 3) ..."
- dtext "","Select the location of your default NewsBox Data file:"
- endif
- dfile Data$,"File,Folder,Disk",128+8+32,0,0,DataUID&
- dtext "","... or choose New to create a new NewsBox Data file"
- if Type%=1
- dbuttons "New",%N,"Relaunch Setup",%S,"Cancel",27,"Continue",13
- else
- dbuttons "New",%N,"Cancel",27,"Continue",13
- endif
- Button%=dialog
- if Button%=13
- if Data$=""
- Data$="*"+Right$(SourceBoxName$,4)
- giprint "No taget file selected"
- goto Startup::
- endif
- elseif Button%=%s
- dinit AppName$+AppVersion$
- dtext "","Relaunch the Setup procedure?"
- dtext "","(you will loose the current settings)"
- dbuttons "Cancel",27,"Continue",13
- if dialog
- delete IniFile$
- if IniSetup%: :return -1 :endif
- else
- goto Startup::
- endif
- elseif Button%=%n
- if exist (SourceBox$)
- Data$=Right$(SourceBoxName$,4)
- dinit AppName$+AppVersion$
- dtext "","Create new NewsBox Data file:"
- dfile Data$,"File,Folder,Disk",1+8
- if Type%=1
- dcheckbox SetDefault%,"Set as default"
- endif
- dbuttons "Cancel",27,"Continue",13
- if dialog
- copy SourceBox$,Data$
- if SetDefault% and Type%=1
- open IniFile$,a,Data$,DataRSC$,MultiBox%,UserDialog%
- a.Data$=Data$
- update
- close
- endif
- else
- goto Startup::
- endif
- else
- Data$="*"+Right$(SourceBoxName$,4)
- giprint "NEW option not available"
- goto Startup::
- endif
- else
- return -1
- endif
- giprint "Target file is "+Data$
- pause 20
- ENDP
-
- PROC UserDialogProc%:
- LOCAL Button%
- dinit AppName$+AppVersion$
- dlong NumMsg&,"Number of articles to archive",1,100
- dtext "","(starting from the highlighted one and going down)",$200
- dcheckbox DelMsg%,"Delete original article from RMRNews"
- dtext "","(use with care, no undelete options available...)",$200
- dbuttons "Cancel",27,"Continue",13
- if dialog
- else
- return -1
- endif
- if DelMsg%
- dinit "Please read carefully:"
- dtext "","You have chosen the ""Auto-Delete"" option, so:"
- dtext "","- DO NOT touch the keyboard and"
- dtext "","- DO NOT switch to any other program"
- dtext "","while the macro is running, as this could also lead to"
- dtext "","the loss of all your articles...",$200
- dtext "","A dialog box will inform you when the task has ended."
- dbuttons "Disable",%D,"Abort",27,"Continue",13
- Button%=dialog
- if Button%=%d
- DelMsg%=0
- giprint """Auto-Delete"" option disabled"
- pause 20
- elseif Button%<>13
- return -1
- endif
- endif
- ENDP
-
- PROC CopyFromNews%:
- LOCAL Dummy$(255)
- FgApp%:(News$)
- SendKey:("Enter") rem open the article
- pause 10
- SendKey:("Ctrl+a") rem select all (from BODY field)
- Dummy$=Copy$:
- if Len(Dummy$)=0 rem article not available off-line
- beep:
- GetFocus:
- giprint "Stop"
- pause 20
- if NumMsg%>1 rem other articles already stored
- FgApp%:(Data$)
- pause 10
- SendKey:("Esc") rem exit from "new entry mode"
- FgApp%:(News$)
- endif
- return -1
- else
- SendKey:("Fn+Up,Fn+Up") rem move to NewsGroups field
- SendKey:("Ctrl+a") rem select all
- Dummy$=Copy$:
- From$=Left$(Dummy$,250)
- SendKey:("Down") rem move to SUBJECT field
- SendKey:("Ctrl+a") rem select all
- Dummy$=Copy$:
- Subject$=Left$(Dummy$,250)
- SendKey:("Down") rem move to BODY field
- pause 20
- Dummy$=Copy$:
- Body$=Left$(Dummy$,250)
- SendKey:("Ctrl+c") rem this copies more than 255 chars
- SendKey:("Esc") rem close article
- pause 20
- endif
- ENDP
-
- PROC AdjustDate:
- rem the following code simply puts the time of archiving
- rem to the date field of the target data file
- Date$=gen$(year,4)+"/"+right$("0"+gen$(month,2),2)+"/"+right$("0"+gen$(day,2),2)
- Date$=Date$+" "+right$("0"+gen$(hour,2),2)+":"+right$("0"+gen$(minute,2),2)+" (*)"
- ENDP
-
- PROC PasteToData:
- FgApp%:(Data$)
- pause 20
- if NumMsg%=1 rem first article (or single article) to store
- SendRscMenu:(DataRSC$,4,&D) rem new entry ("Ctrl+Shift+n" for UK/USA)
- endif
- pause 20
- SendKey:("Tab,Tab,Tab,Tab,Tab") rem move to BODY field
- SendKey:("Ctrl+v")
- pause 20
- SendKey:("Shift+Tab") rem move to CC/BCC field
- SendKey:("Shift+Tab") rem move to TO field
- SendKey:("Shift+Tab") rem move to FROM field
- Paste:(From$)
- pause 20
- SendKey:("Shift+Tab") rem move to DATE field
- Paste:(Date$)
- pause 20
- SendKey:("Shift+Tab") rem move to TITLE field
- if Subject$<>""
- Paste:(Subject$)
- endif
- pause 20
- SendRscMenu:(DataRSC$,4,&16) rem save article ("Ctrl+s" for UK/USA)
- if NumMsg%=NumMsg& rem last article (or single article) stored
- SendKey:("Esc") rem exit from "new entry mode"
- endif
- ENDP
-
- PROC Report:
- GetFocus:
- if Len(From$)=250 or Len(Subject$)=250
- dinit AppName$+" warning"
- dtext "","Check if the last saved article contains one of the"
- dtext "","From or Subject fields exceeding the 250 chars limit"
- if NumMsg&>1
- NumMsg%=NumMsg&
- dtext "","The archiving procedure has been stopped..."
- endif
- if DelMsg%
- dtext "","The original article won't be deleted from RMRNews"
- endif
- dbuttons "Continue",13
- dialog
- SendKey:("Esc") rem exit from "new entry mode" (if necessary)
- else
- if NumMsg&>1 rem storing a group of articles
- giprint "Article "+gen$(NumMsg%,3)+" of "+gen$(NumMsg&,3)+" stored"
- else
- giprint "New article stored"
- endif
- pause 20
- FgApp%:(News$)
- pause 20
- if DelMsg%
- Sendkey:("Del") rem delete current article
- Sendkey:(YesBtn$) rem confirm deletion with "Yes" button
- pause 20
- else
- SendKey:("Down") rem move down to the next article
- endif
- if NumMsg%=NumMsg& and (NumMsg&>1 or DelMsg%) rem last article of a group
- GetFocus:
- dinit AppName$+AppVersion$
- dtext "",gen$(NumMsg&,3)+" article(s) successfully stored to:"
- dtext "",Data$
- dbuttons "Continue",13
- dialog
- endif
- endif
- ENDP
-
-
-