REM Modify a notes entry
REM Called when a user wants to edit an entry
REM Title:      Director:Menus.IntNotes.Edit
REM Author:     Philip Ludlam
REM Version:    0.31 Beta, Saturday the 3rd of November, 2001
REM Copyright:  (C) Philip Ludlam 2001

REM This program is free software; you can redistribute it and/or modify it
REM under the terms of the GNU General Public License as published by the Free
REM Software Foundation; either version 2 of the License, or (at your option)
REM any later version.
REM
REM This program is distributed in the hope that it will be useful, but WITHOUT
REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
REM FITNESS FOR APARTICULAR PURPOSE. See the GNU General Public License for more
REM details.
REM
REM You should have received a copy of the GNU General Public License along with
REM this program; if not, write to the Free Software Foundation, Inc., 59 Temple
REM Place - Suite 330, Boston, MA 02111-1307, USA

ON ERROR PROCerror

DIM block% 1023,syntax% 255,output% 255,file_area% 2047
file_size%=0:file_ptr%=0

Menu=FNswi_number("Director_Menu")
EndMenu=FNswi_number("Director_EndMenu")
Option=FNswi_number("Director_Option")
Command=FNswi_number("Director_Command")
Dash=FNswi_number("Director_Dash")

REM Get command line
SYS "OS_GetEnv" TO comm%
REM VDU4:PRINT FNstring(comm%)
SYS "OS_ReadArgs","name,quit,file,line",comm%,block%,1023

IF block%!8=0 THEN
  file$="Director:Menus.IntNotes.Notes.Notes"
ELSE
  file$=FNstring(block%!8)
  IF INSTR(file$,"$")=0 AND INSTR(file$,":")=0 file$="Director:Menus.IntNotes.Notes."+file$
ENDIF
line%=EVAL(FNstring(block%!12))

IF FNfile_valid(file$,1) THEN
  PROCfile_load(file$)
  line$=FNfile_read:lineno%=1
  WHILE line%>lineno%
    line$=FNfile_read:lineno%+=1
  ENDWHILE

  SYS "OS_ReadArgs","/a,priority/k,sub/k,notes/k",line$,block%,1024
  text$=FNstring(!block%)
  IF block%!4<>0 pri$="-fg <"+FNstring(block%!4)+">":pril$=FNlcase(FNstring(block%!4)) ELSE pri$="":pril$="standard"
  IF block%!8<>0 sub$=FNstring(block%!8) ELSE sub$=""
  IF block%!12<>0 notes$=FNstring(block%!12) ELSE notes$=""

  PROCmenu_notesedit
  PROCmenu_notesname
  PROCmenu_notesnotes
  PROCmenu_notesmore
  PROCmenu_notesmove
  PROCmenu_notespriority
ELSE
  SYS Menu,"Edit NotesEdit"
  SYS EndMenu
ENDIF
*Set Director$Menu NotesEdit

END

:

DEF PROCmenu_notesedit
SYS Menu,"Edit NotesEdit"
SYS Option,"Name -sub NotesName"
SYS Option,"Notes -sub NotesNotes"
SYS Option,"More -sub NotesMore"
SYS Option,"Move -sub NotesMove"
SYS Option,"Priority -sub NotesPriority"
SYS Option,"Remove"
SYS Command,"Run Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -remove"
SYS EndMenu
ENDPROC

:

DEF PROCmenu_notesname
SYS Menu,"Name NotesName"
SYS Option,""""+text$+""" -len 256"
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -edit ""<MenuText>"""
SYS EndMenu
ENDPROC

:

DEF PROCmenu_notesmore
SYS Menu,"More NotesMore"
IF sub$<>"" THEN
  SYS Option,sub$+" -len 256"
ELSE
  SYS Option,""""" -len 256"
ENDIF
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -sub ""<MenuText>"""
SYS EndMenu
ENDPROC

:

DEF PROCmenu_notesnotes
SYS Menu,"Notes NotesNotes"
IF notes$<>"" THEN
  SYS Option,""""+notes$+""" -len 256"
ELSE
  SYS Option,""""" -len 256"
ENDIF
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -notes ""<MenuText>"""
ENDPROC

:

DEF PROCmenu_notesmove
SYS Menu,"Move NotesMove"
SYS Option,"Top"
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -move Top"
SYS Option,"Up"
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -move Up"
SYS Option,"Down"
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -move Down"
SYS Option,"Bottom"
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -move Bottom"
SYS EndMenu
ENDPROC

:

DEF PROCmenu_notespriority
SYS Menu,"Priority NotesPriority"
IF pril$="urgent" tick$=" -tick" ELSE tick$=""
SYS Option,"Urgent -fg <Director$Notes$Urgent>"+tick$
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -priority Urgent"
IF pril$="important" tick$=" -tick" ELSE tick$=""
SYS Option,"Important -fg <Director$Notes$Important>"+tick$
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -priority Important"
IF pril$="standard" tick$=" -tick" ELSE tick$=""
SYS Option,"Standard -fg <Director$Notes$Standard>"+tick$
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -priority Standard"
IF pril$="dull" tick$=" -tick" ELSE tick$=""
SYS Option,"Dull -fg <Director$Notes$Dull>"+tick$
SYS Command,"/Director:Menus.IntNotes.Modify -file """+file$+""" -line "+STR$(lineno%)+" -priority Dull"
SYS EndMenu
ENDPROC

:

DEF PROCmenu_notenew
SYS Menu,"""New "" Note"
SYS Option,""""" -len 256 -sub"
SYS EndMenu
ENDPROC

:

DEF FNswi_number(n$)
SYS "OS_SWINumberFromString",,n$ TO a%
=a%

:

DEF FNstring(p%):LOCAL a$:a$=""
WHILE ?p%>31
  a$+=CHR$(?p%):p%+=1
  ENDWHILE:=a$

:

DEF FNstring_c(s%,l%):LOCAL a$,p%:a$="":p%=0
WHILE s%?p%>31 AND p%<=l%
  a$+=CHR$(s%?p%):p%+=1
  ENDWHILE:=a$

:

REM want% = to what object type you want to find/are looking for
DEF FNfile_valid(file$,want%):LOCAL ans%
SYS "XOS_File",17,file$ TO ans%
=(ans%=want%)

:

DEF PROCfile_load(file$)
LOCAL len%
SYS "OS_File",16,file$,file_area% TO ,,,,len%
file_area%?len%=0
file_size%=len%
ENDPROC

:

DEF FNfile_read
LOCAL i$:i$=""
WHILE i$=""
  i$=FNstring_c(file_area%+file_ptr%,file_size%-file_ptr%)
  file_ptr%+=LEN(i$)+1
  ENDWHILE
=i$

:

DEF FNlcase(text$)

LOCAL Loop%,text2$
text2$=STRING$(LEN(text$)," ")
text2$=""

FOR Loop%=1 TO LEN(text$)
  chr%=ASC(MID$(text$,Loop%,1))
  IF chr%>64 AND chr%<91 chr%=chr%+32
  text2$+=CHR$(chr%)
NEXT

=text2$


:

DEF PROCerror
ON ERROR OFF
VDU 4
PRINT "Error in: !Director.Menus.IntNotes.Edit"
PRINT "Report:   ";REPORT$
PRINT "Line:     ";ERL
END

:
