home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
c
/
charter
/
!Charter
/
Source203
(
.txt
)
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
RISC OS BBC BASIC V Source
|
1997-05-20
|
41.9 KB
|
1,746 lines
*****************************************************************
* Initiallisation code *
*****************************************************************
>version$="2.03 (19-May-1997)"
myid$="Charter 2.03"
_Initialise
Block% 256
_ErrorHandler
_Variables
Giconbar_icon%=
_IconCreate(-1,0,0,88,68,%10000000000010,"!Charter")
_TemplatesLoad
_Menus
_ScreenReadSize
_OptionsLoad
_Messages
_IconWrite(info%,7,version$)
_IconFlags(toolbox%,0,22,
Pointer icon selected
_IconFlags(edit%,5,23,
) :
Undo Button greyed out
_IconFlags(options%,3,22,
_LoadFiles(
_ReadSysVar("Charter$Default"))
_TextLoad
_ErrorHandler
*****************************************************************
* Wimp Poll *
*****************************************************************
"Wimp_Poll",,Block%
reason%
reason%
)8
0 :
getpos%=
_CalculateCoords
1 :
_Redraw
2 :
Block%!0=main%
,$
_Window_OpenMany
-.
"Wimp_OpenWindow",,Block%
3 :
Block%!0=main%
0$
_Window_CloseMany
1/
"Wimp_CloseWindow",,Block%
3
4 :
_Window_PointerOut
5 :
_Window_PointerIn
5I
6 :
_MouseClick(Block%!12,Block%!16,Block%!8,Block%!0,Block%!4)
6,
7 :
_DragEnd(
_IconRead(save%,0))
76
8 :
_KeyPressed(Block%!0,Block%!4,Block%!24)
9 :
_Menu_Decode
17,18,19:
_Receive
*****************************************************************
* Menu definitions *
*****************************************************************
_Initialise
usermsg% 44
usermsg%!0=0
usermsg%!4=1
usermsg%!8=2
usermsg%!12=3
usermsg%!16=5
usermsg%!20=10
usermsg%!24=&502
usermsg%!28=&503
usermsg%!32=&400C2
usermsg%!36=&400CC
usermsg%!40=0
"Wimp_Initialise",300,&4B534154,myid$,usermsg%
riscos%,myid%
_Variables
"THHeap_CreateGranular","Charter Data",200000,12
heap%
"THHeap_CreateGranular","Charter Memory",200000,12
memory%
"THHeap_Claim",memory%,8
,,undo% :
this is the undo buffer
V8undosize%=0 :
this is the index of the undo buffer
header% 40
table% 24 :
Font table
header2% 88
pos%=0
[5n%=-4 :
current position in the stack
max%=0
]Lgetpos%=
:
Determines whether to calculate and display coordinates.
clear%=
textopen%=
dragicon$="file_aff"
stackmade%=
notext%=
"THHeap_Claim",memory%,256
,,Buffer%
"THHeap_Claim",memory%,4
,,textbuf%
textpos%=0
f!currentfont$="Trinity.Medium"
fontsize%=16
textobj%=0
helpfile$="!Help"
j)textwidth%=960:maxlines%=256:lines%=0
_Menus
"MenuUtil_Initialise",010,0
"MenuUtil_New",,"Font List"
menu_fonts%
count%,font$
s9
"Font_ListFonts",,Block%,count%,-1
,,count%
font$=
_String(Block%)
u/
"MenuUtil_Add",menu_fonts%,font$,"
count%=-1
"MenuUtil_New",,"Charter"
menu_iconbar%
y!
"MenuUtil_Add",,"Info"
z&
"MenuUtil_SubMenu",,info%
{$
"MenuUtil_Add",,"Options
"MenuUtil_Dots",,
}
"MenuUtil_Add",,"Quit"
"MenuUtil_New",,"Size"
menu_size%
"MenuUtil_Add",,"12","!"
"MenuUtil_Add",,"16","!"
"MenuUtil_Add",,"24","!"
"MenuUtil_Add",,
(fontsize%),"!"
,
"MenuUtil_Writable",,
,3,"A0-9"
"MenuUtil_New",,"Text"
menu_text%
"MenuUtil_Add",,"Font"
,
"MenuUtil_SubMenu",,menu_fonts%
"MenuUtil_Add",,"Size"
+
"MenuUtil_SubMenu",,menu_size%
"MenuUtil_Dots",,
"MenuUtil_Add",,"Undo"
menu_undo%
/
"MenuUtil_Fade",menu_undo%,notext%
"MenuUtil_New",,"Save as
menu_save%
"MenuUtil_Add",,"Drawfile"
"MenuUtil_Add",,"CSV"
"MenuUtil_Add",,"Data"
"MenuUtil_Add",,"DXF"
"MenuUtil_New",,"Charter"
menu_window%
"MenuUtil_Add",,"Info"
&
"MenuUtil_SubMenu",,info%
"MenuUtil_Add",,"Help"
)
"MenuUtil_SubMenu",,helpwin%
"MenuUtil_Add",,"Text"
.
"MenuUtil_SubMenu",,menu_text%
"MenuUtil_Add",,"Save
"MenuUtil_Add",,"Edit
"MenuUtil_Add",,"Options
_Menu_Decode
handler%,adjust%,item%,handler$
"MenuUtil_Decode",,Block%
handler%,adjust%,item%
item$=$(item%!12)
handler$=$(handler%)
item$
"Quit" :
_CloseDown
"Edit
" :
_Window_Open(edit%,-1,-1)
"Save
" :
_Window_Open(save%,-1,-1)
"Options
" :
_Window_Open(options%,-1,-1)
"Drawfile" :
_IconSwap("file_aff",item$)
"CSV" :
_IconSwap("file_2ad",item$)
"Data" :
_IconSwap("file_ffd",item$)
"DXF" :
_IconSwap("file_dea",item$)
"Undo" :
_TextUndoLast
handler$="!"
fontsize%=
(item$)
5
handler$="
currentfont$=item$
adjust%
"MenuUtil_Show"
_IconSwap(filetype$,item$)
save_icon%,iminx%,iminy%,imaxx%,imaxy%
_IconWrite(save%,3,item$)
Block%!0=save%
Block%!4=1
"Wimp_GetIconState",,Block%
iminx%=Block%!8
iminy%=Block%!12
imaxx%=Block%!16
imaxy%=Block%!20
"Wimp_DeleteIcon",,Block%
Rsave_icon%=
_IconCreate(save%,iminx%,iminy%,imaxx%,imaxy%,&C000601A,filetype$)
"Wimp_ForceRedraw",save%,iminx%,iminy%,imaxx%,imaxy%
dragicon$=filetype$
*****************************************************************
* Template definitions *
*****************************************************************
_TemplatesLoad
templates% 622
(maxws%=1010 :
Indirected data total
ws% maxws%:curws%=ws%
"Wimp_OpenTemplate",,"<Charter$Dir>.Templates"
&info%=
_TemplatesCreate("info")
&save%=
_TemplatesCreate("save")
)options%=
_TemplatesCreate("options")
&main%=
_TemplatesCreate("main")
&pane%=
_TemplatesCreate("pane")
)toolbox%=
_TemplatesCreate("toolbox")
&edit%=
_TemplatesCreate("edit")
&text%=
_TemplatesCreate("text")
)helpwin%=
_TemplatesCreate("help")
"Wimp_CloseTemplate"
_TemplatesCreate(window$)
"Wimp_LoadTemplate",,templates%,curws%,ws%+maxws%,-1,window$,0
,,curws%
"Wimp_CreateWindow",,templates%
result%
=result%
*****************************************************************
* Mouse actions *
*****************************************************************
_MouseClick(window%,icon%,button%,mousex%,mousey%)
window%=-2
icon%=iconbar_icon%
button%
6
"MenuUtil_Show",menu_iconbar%,Block%
4: Block%!0=main%
wsizey%
2
"Wimp_GetWindowState",,Block%
, wsizey%=Block%!16-Block%!8
B
_Window_Open(main%,64,sch%-wsizey%-
_TitleSize)
2 Block%!0=main%:
_Window_OpenMany
window%
options%
icon%
3 : clear%=
2 : clear%=
save%
icon%
,
1 :
_DragStart(save%)
8
3 :
"MenuUtil_Show",menu_save%,Block%
text%
icon%
F
2 :
button%=2
"MenuUtil_Show",menu_text%,Block%
main%
button%
:
2 :
"MenuUtil_Show",menu_window%,Block%
.
4 :
_WindowVisible(text%)
6
_TextPlace(mousex%,mousey%)
edit%
icon%
4 :
_ValueEdit
5 :
_ValueUndo
?
6 :
_IconValueIncrement(edit%,1,-1,
,1,n%/4)
. :
_ValueCurrent
?
7 :
_IconValueIncrement(edit%,1,+1,
,1,n%/4)
% :
_ValueCurrent
<
8 :
_IconValueIncrement(edit%,3,-1,
,0,0)
<
9 :
_IconValueIncrement(edit%,3,+1,
,0,0)
toolbox%
icon%
+
0 : textopen%=
_TextToggle
9
1 : textopen%=textopen%
-1 :
_TextToggle
*****************************************************************
* Actions when message is received from the WIMP *
*****************************************************************
_Receive
Block%!16
0 :
_CloseDown
(2
1 : Block%!0=(48+
("<Wimp$Scrap> "))
)" Block%!12=Block%!8
*. Block%!16=2 :
DataSaveAck
++ $(Block%+44)="<Wimp$Scrap>"
,8
"Wimp_SendMessage",17,Block%,Block%!4
2 :
_MessageSaveAck
3,5 :
Block%!40
&2AD,&2AC,&FFD
1" Block%!12=Block%!8
23 Block%!16=4 :
Message_DataLoadAck
37
"Wimp_SendMessage",17,Block%,main%,0
47
This stops the run action being taken
50
_LoadFiles(
_String(Block%+44))
7!
&502 :
_HelpDefinitions
8!
&400CC :
_WindowIconise
9@
&400C2:newtaskid%=Block%!4:newtask$=
_String(Block%+28)
:9
newtask$=myid$
newtaskid%<>myid%
_CloseDown
;%
10:
_SaveDesktop(Block%!20)
_SaveDesktop(file%)
Block%!12=Block%!8:
"Wimp_SendMessage",19,Block%,Block%!4:
The above line acknowledges the message if an error occurs, thereby
aborting the desktop save.
#file%,"Run <Charter$Dir>.!RunImage"
_SaveAs(filename$)
filetype$
J!filetype$=
_IconRead(save%,3)
filetype$
L+
"Drawfile" :
_SaveDraw(filename$)
M3
_SaveEnd("AFF",filename$)
N*
"CSV" :
_SaveCSV(filename$)
O3
_SaveEnd("2AD",filename$)
P+
"Data" :
_SaveData(filename$)
Q3
_SaveEnd("FFD",filename$)
R*
"DXF" :
_SaveDXF(filename$)
S3
_SaveEnd("DEA",filename$)
_MessageSaveAck
filename$
Y!filename$=
_String(Block%+44)
_IconWrite(save%,0,filename$)
_SaveAs(filename$)
Block%!0=40+
filename$+4
Block%!0+=4-(Block%!0
_$Block%!16=3 :
Message_DataLoad
Block%!36=0
Block%!40=&FF8
$(Block%+44)=filename$+
"Wimp_SendMessage",18,Block%,senderwindow%,sendericon%
_CloseDown
"THHeap_RemoveHeap",heap%
"THHeap_RemoveHeap",memory%
"Wimp_CloseDown"
*****************************************************************
* Error Handling *
*****************************************************************
_ErrorHandler
"Wimp_CloseDown":
result%
"Wimp_DragBox",,-1
w4
2001 : error$=
_LookupString("ERRHP",
x;
2002 : error$=
_LookupString("ERRF1",
~Block%!40)
yA
2003 : error$=
_LookupString("ERRTL",thisfile$):
#file%
z1
2004 : error$=
_Lookup("ERRCD"):
#file%
{2
2005 : error$=
_Lookup("ERRNRD"):
#file%
|9
: error$="Error "+
)+" at Line "+
)+": "+
!Block%=
:$(Block%+4)=error$
"Wimp_ReportError",Block%,%10011,"Charter"
,result%
result%=2
_CloseDown
*****************************************************************
* Drag routines *
*****************************************************************
_DragStart(window%)
!Block%=window%
"Wimp_GetWindowState",,Block%
wposx%=Block%!4-Block%!20
wposy%=Block%!16-Block%!24
@Block%!0=window% :
Window owning the icon
<Block%!4=1 :
Icon to be dragged
"Wimp_GetIconState",,Block%
Block%!0=Block%!8+wposx%
Block%!4=Block%!12+wposy%
Block%!8=Block%!16+wposx%
Block%!12=Block%!20+wposy%
"DragASprite_Start",%11001111,1,dragicon$,Block%
_DragEnd(leafname$)
"DragASprite_Stop"
pointer%
pointer%=
leafname$
pointer%>0
leafname$,pointer%,1)<>"."
pointer%-=1
$leafname$=
leafname$,pointer%+1)
"Wimp_GetPointerInfo",,Block%
senderwindow%=Block%!12
sendericon%=Block%!16
Block%!20=senderwindow%
Block%!24=sendericon%
Block%!28=Block%!0
Block%!32=Block%!4
Block%!0=44+
leafname$
Block%!0+=4-(Block%!0
Block%!4=0
Block%!8=0
Block%!12=0
$Block%!16=1 :
Message_DataSave
+Block%!36=0 :
Length of proposed save
Block%!40=&AFF
$(Block%+44)=leafname$+
"Wimp_SendMessage",17,Block%,senderwindow%,sendericon%
*****************************************************************
* Icon handling *
*****************************************************************
_IconRead(window%,icon%)
result$
Block%!0=window%
Block%!4=icon%
"Wimp_GetIconState",,Block%
(Block%!24
(1<<8))<>0
result$=$(Block%!28)
result$=$(Block%+28)
=result$
_IconWrite(window%,icon%,text$)
BBlock%!0=window%:Block%!4=icon%:
"Wimp_GetIconState",,Block%
(text$)>(Block%!36)-1
((Block%!24)
(1<<9))=(1<<9)
Right-justified
' text$="
text$,(Block%!36)-2)
#
Left-justified or centred
/ text$=
text$,(Block%!36)-1):
text$)="
^ Ensures the text can't overflow the maximum space in the icon.
$(Block%!28)<>text$
/ $(Block%!28)=text$:Block%!8=0:Block%!12=0
"Wimp_SetIconState",,Block%
"Wimp_GetCaretPosition",,Block%
Block%!0=window%
Block%!4=icon%
If this icon owns the caret, then put it at the end.
"Wimp_SetCaretPosition",window%,icon%,0,0,-1,
(text$)
_IconFlags(window%,icon%,bit%,status%)
Block%!0=window%
Block%!4=icon%
status%
Block%!8=1<<(bit%-1)
Block%!8=0
Block%!12=1<<(bit%-1)
"Wimp_SetIconState",,Block%
_IconValueIncrement(window%,icon%,change%,minlimit%,maxlimit%,minval%,maxval%)
size%
&size%=
_IconRead(window%,icon%))
size%+=change%
maxlimit%=-1
size%>maxval%
size%=maxval%
minlimit%=-1
size%<minval%
size%=minval%
_IconWrite(window%,icon%,
(size%))
_IconCreate(window%,xmin%,ymin%,xmax%,ymax%,flags%,sprite$)
icon%
Block%!0=window%
Block%!4=xmin%
Block%!8=ymin%
Block%!12=xmax%
Block%!16=ymax%
Block%!20=flags%
$(Block%+24)=sprite$
"Wimp_CreateIcon",,Block%
icon%
=icon%
*****************************************************************
* Miscellaneous *
*****************************************************************
_ScreenReadSize
xw%,xh%,xf%,yf%
"OS_ReadModeVariable",
,,xw%
"OS_ReadModeVariable",
,,xh%
"OS_ReadModeVariable",
,,xf%
"OS_ReadModeVariable",
,,yf%
scw%=xw%<<xf%
sch%=xh%<<yf%
_String(pointer%)
Reads a zero terminated string
result$
result$+=
?pointer%
pointer%+=1
?pointer%=0
?pointer%=13
=result$
_KeyPressed(window%,icon%,char%)
"Wimp_GetPointerInfo",,Block%
Block%!12
main%
char%
9
&184 :
_IconWrite(edit%,1,
(relative_x%))
<
_IconWrite(edit%,3,
(relative_y%))
3
_Window_Open(edit%,-1,-1)
0
&188 :
_TextUndoLast
(
"Wimp_ProcessKey",char%
edit%
char%
-
13 :
icon%=3
_ValueEdit
!
&188 :
_ValueUndo
)
"Wimp_ProcessKey",char%
#
"Wimp_ProcessKey",char%
_Filetype(filename$)
loadaddress%,type%,result%
"OS_File",17,filename$
type%,,loadaddress%
type%<>1
result%=-2
(loadaddress%>>>20)=&FFF
result%=0
result%=(loadaddress%>>>8)
result%=0
result%=-1
=result%
_Pad(text$)
result$,count%
result$=text$
(text$)
4<>0
0%
count%= 1
(text$)
result$+=
=result$
_TitleSize
result%
8Qresult%=
((Block%!32)
(1<<26))=(1<<26)
((Block%!32)
1)=1
result%=
result%
_ReadSysVar(sysvar$)
eg. FN_ReadSysVar("Charter$Default")
var% 256
$(var%)=sysvar$
"OS_ReadVarVal",var%,Buffer%,256,,3
,,pointer%
Buffer%?(pointer%)=13
=$Buffer%
*****************************************************************
* Window routines *
*****************************************************************
_Window_Open(window%,x%,y%)
If x% and y% =-1 (TRUE) then the window is centered
wsizex%,wsizey%
Block%!0=window%
"Wimp_GetWindowState",,Block%
wsizex%=Block%!12-Block%!4
wsizey%=Block%!16-Block%!8
Q! Block%!4=(scw%-wsizex%)/2
R! Block%!8=(sch%-wsizey%)/2
Block%!4=x%
Block%!8=y%
Block%!12=Block%!4+wsizex%
Block%!16=Block%!8+wsizey%
Block%!28=-1
"Wimp_OpenWindow",,Block%
_WindowVisible(window%)
result%
Returns TRUE if window is open; false otherwise
a5Block%!0=window%:
"Wimp_GetWindowState",,Block%
((Block%!32)
(1<<16))=(1<<16)
result%=
result%=
=result%
_Window_PointerIn
getpos%=
"Wimp_GetPointerInfo",,Block%
"Wimp_SetCaretPosition",Block%!12,-1,0,0,-1,-1
_Window_PointerOut
getpos%=
_IconWrite(pane%,0,"(x,y)")
_Window_Close(window%)
Block%!0=window%
"Wimp_GetWindowState",,Block%
"Wimp_CloseWindow",,Block%
_Window_Resize(window%,xmin%,ymin%,xmax%,ymax%)
Block%!0=xmin%
Block%!4=ymin%
Block%!8=xmax%
Block%!12=0-ymax%
"Wimp_SetExtent",window%,Block%
Block%!0=window%
"Wimp_GetWindowState",,Block%
Block%!4=xmin%+64
Block%!8=ymin%-
_TitleSize
Block%!12=xmax%+64
Block%!16=sch%-
_TitleSize
Block%!28=-1
_Window_OpenMany
window%=helpwin%
Block%!0=window%
"Wimp_GetWindowState",,Block%
Block%!4=xmin%
Block%!8=ymin%
Block%!12=xmax%
Block%!16=sch%
Block%!28=-1
_Window_OpenMany
main_minx%,main_miny%,main_maxx%
Block%!0=main%
"Wimp_OpenWindow",,Block%
"Wimp_GetWindowOutline",,Block%
main_minx%=Block%!4
main_miny%=Block%!8
main_maxx%=Block%!12
main_maxy%=Block%!16
Block%!0=pane%
Block%!4=main_minx%+42
Block%!8=main_miny%-38
Block%!12=main_maxx%
Block%!16=main_miny%
"Wimp_OpenWindow",,Block%
Block%!0=toolbox%
Block%!4=main_minx%-64
-Block%!8=312:
for resizing main_miny%+38
Block%!12=main_minx%
Block%!16=main_maxy%-38
"Wimp_OpenWindow",,Block%
textopen%=
Block%!0=text%
Block%!4=main_minx%+250
Block%!8=main_miny%-38
Block%!12=main_maxx%
Block%!16=main_miny%
"Wimp_OpenWindow",,Block%
_Window_CloseMany
_Window_Close(main%)
_Window_Close(pane%)
_Window_Close(text%)
_Window_Close(toolbox%)
_WindowIconise
HBlock%!0=56:Block%!12=Block%!8:Block%!16=&400CC:
Message_WindowInfo
Block%!20<>0
Block%!24=0
< $(Block%+28)="charter"+
0 :
uses sprite ic_<name>
: $(Block%+36)="Charter" :
uses text <name>
"Wimp_SendMessage",17,Block%,Block%!4
*****************************************************************
* Interactive Help *
*****************************************************************
_HelpDefinitions
9Block%!12=Block%!8:Block%!16=&503:helpinfo%=Block%+20
Block%!32
_HelpSend(
_Lookup("PRG1"))
(
_HelpSend(
_Lookup("PRG2"))
(
_HelpSend(
_Lookup("PRG3"))
options%:
Block%!36
/
2 :
_HelpSend(
_Lookup("OPTCON"))
.
3 :
_HelpSend(
_Lookup("OPTCL"))
save%
Block%!36
+
_HelpSend(
_Lookup("SAVD"))
+
_HelpSend(
_Lookup("SAVT"))
.
_HelpSend(
_Lookup("SAVF"))
+
_HelpSend(
_Lookup("SAVN"))
pane%
Block%!36
+
_HelpSend(
_Lookup("COOD"))
text%
Block%!36
*
_HelpSend(
_Lookup("TXT"))
toolbox%
Block%!36
+
0 :
_HelpSend(
_Lookup("TBP"))
+
1 :
_HelpSend(
_Lookup("TBT"))
edit%
Block%!36
+
_HelpSend(
_Lookup("EDDP"))
+
_HelpSend(
_Lookup("EDNV"))
+
_HelpSend(
_Lookup("EDCV"))
+
_HelpSend(
_Lookup("EDUN"))
0
6,7,8,9:
_HelpSend(
_Lookup("EDAL"))
info%:
_HelpSend(
_Lookup("INF"))
main%:
_HelpSend(
_LookupString("MAIN",thisfile$))
9
textopen%
_HelpSend(
_Lookup("TXTN"))
"Wimp_GetMenuState",1,Buffer%,Block%!32,Block%!36
item%,item$
?
"MenuUtil_Decode",,Buffer%
handler%,,item%
! item$=$(item%!12)
$ handler$=$(handler%)
item$
;
"Info" :
_HelpSend(
_Lookup("MNINF"))
;
"Text" :
_HelpSend(
_Lookup("MNTXT"))
;
"Save
_HelpSend(
_Lookup("MNSV"))
;
"Edit
_HelpSend(
_Lookup("MNED"))
?
"Options
_HelpSend(
_Lookup("MNOPT"))
:
"Font" :
_HelpSend(
_Lookup("MNFO"))
:
"Size" :
_HelpSend(
_Lookup("MNSZ"))
:
"Undo" :
_HelpSend(
_Lookup("MNUN"))
?
"Drawfile" :
_HelpSend(
_Lookup("MNAFF"))
;
"Data" :
_HelpSend(
_Lookup("MNFFD"))
?
_HelpSend(
_Lookup("MNFFD2"))
:
"CSV" :
_HelpSend(
_Lookup("MN2AD"))
>
_HelpSend(
_Lookup("MN2AD2"))
:
"DXF" :
_HelpSend(
_Lookup("MNDEA"))
>
_HelpSend(
_Lookup("MNDEA2"))
&
handler$="
H
_HelpSend(
_LookupString("MNFONT",item$))
.
handler$="!"
H
_HelpSend(
_LookupString("MNSIZE",item$))
?helpinfo%=0
'Block%!0=(helpinfo%+4-Block%)
"Wimp_SendMessage",17,Block%,Block%!4
_HelpSend(text$)
$helpinfo%=text$+"|M"
helpinfo%+=
(text$)+2
*****************************************************************
* Data Loading Routines *
*****************************************************************
_LoadFiles(filename$)
thisfile$=filename$
_Filetype(filename$)
*)
&2AC,&2AD :
_LoadCSV(filename$)
+*
&FFD :
_LoadData(filename$)
_LoadStart(filename$,type%)
max%=0
clear%
n%=-4
_StackRemove
"Hourglass_On"
type%<> &FFD
_StackExtend(100000)
oldn%=n%
file%=
filename$
oldn%=0
_LoadEnd(type%)
#file%
a%=0
A(
stack%!a%>max%
max%=stack%!a%
_Window_Resize(main%,0,-max%,n%,0)
"Wimp_ForceRedraw",main%,0,-max%,n%,0
_Redraw
_ValueCurrent
"Hourglass_Off"
clear%
newn%=n%
newn%=n%-oldn%
type%<>&FFD
"THHeap_Extend",heap%,(newn%+4-100000),stack%
_LoadCSV(filename$)
_LoadStart(filename$,&2AD)
stringfromfile$
#file%
U n%+=4
"String_Get$#",Buffer%,file%,256,10,0
stringfromfile$
W" stack%!n%=
(stringfromfile$)
"Hourglass_Percentage",(n%/
#file%)*100
_LoadEnd(&2AD)
_LoadData(filename$)
a%,byte%,string$,textpos1%,textpos2%
file%=
(filename$)
"String_Get$#",Buffer%,file%,14,0,0
string$
string$,1,7)="Charter"
textobj%=
#file%
textpos1%=
#file%
textpos2%=
#file%
e) textpos%=(textpos1%<<8) +textpos2%
f(
#file%=
#file%+1 :
1 spare byte
g& datalength%=
#file%-textpos%-16
textobj%>0
End of header
j+
"THHeap_Free",memory%,textbuf%
k9
"THHeap_Claim",memory%,textpos%
,,textbuf%
lD
"OS_GBPB",3,file%,textbuf%,textpos%,
#file%
,,,,fptr%
#file%=fptr%
o"
_LoadStart(filename$,&FFD)
q;
"THHeap_Claim",memory%,datalength%
,,tempstack%
r?
"OS_GBPB",3,file%,tempstack%,
#file%-textpos%,
#file%
s!
_StackExtend(datalength%)
tM
"Wimp_TransferBlock",myid%,tempstack%,myid%,stack%+n%+4,datalength%
n%=n%+datalength%
_LoadEnd(&FFD)
w*
"THHeap_Free",memory%,tempstack%
2005,"" :
Not the right format
*****************************************************************
* Data Saving Routines *
*****************************************************************
_SaveEnd(type$,filename$)
#file%
"Hourglass_Off"
"SetType "+filename$+" "+type$
"Wimp_CreateMenu",,-1
_WindowVisible(save%))=
_Window_Close(save%)
_SaveCSV(filename$)
"Hourglass_On"
offset%,current_datapoint%,y%
&offset%=
_IconRead(options%,43))
file%=
filename$
current_datapoint%=0
. y%=(stack%!current_datapoint%)+offset%
#file%,
=
"Hourglass_Percentage",(current_datapoint%/n%)*100
_SaveData(filename$)
"Hourglass_On"
file%=
filename$
title% 12
a%=0
" title%?a%=
myid$,a%+1,1))
"OS_GBPB",1,file%,title%,12
#file%,0:
End of Header byte
#file%,textobj%
#file%,(textpos%>>8)
#file%,(textpos%
256) :
cos textpos% is likely to be >255
#file%,&0D :
a spare byte - glad I had the last one!
textobj%>0
"OS_GBPB",2,file%,textbuf%,textpos%,
#file%+4
"OS_GBPB",2,file%,stack%,n%+4
,,,fptr%
_SaveDraw(filename$)
"Hourglass_On"
count%,elements%,maxelements%,x%,y%
maxelements%=100
%pathsize%=(68+(maxelements%*4*3))
file%=
filename$
fptr%=0
"OS_GBPB",1,file%,header%,40,fptr%
,,,,fptr%
"OS_GBPB",1,file%,table%,24,fptr%
,,,,fptr%
"OS_GBPB",1,file%,header2%,88,fptr%
,,,,fptr%
_PathStart
_PathMove(x%,0)
count%=0
x%+=900
& y%=max%*220-(stack%!count%)*220
_PathDraw(x%,y%)
elements%+=1
elements%>maxelements%
elements%=0
_PathEnd
_PathStart
_PathMove(x%,y%)
"Hourglass_Percentage",(count%*100/n%)
_PathEnd
textobj%>0
_SaveDrawText
_SaveDrawText
count%,font%,units%,endpos%
textlength%,objlength%,size%,x%,y%,text$,font$
object%=1
textobj%
#textlength%=textbuf%?(count%+2)
#objlength%= textbuf%?(count%+1)
'size%= textbuf%?(count%+3)*640
#x%= textbuf%!(count%+4)
#y%= textbuf%!(count%+8)
&text$ =$(textbuf%+12+count%)
2font$ =$(textbuf%+12+count%+textlength%)
font%=1
text$=
_Pad(text$)
endpos%=52+
(text$)
"THHeap_Claim",memory%,endpos%+4
,,drawstack%
x%=x%*225
y%=(max%*221)+(y%*227)
Ddrawstack%!0=1 :
Beginning of a Text Object
4drawstack%!8=(0) :
Bound Left
6drawstack%!12=(0) :
Bound Bottom
5drawstack%!16=(0) :
Bound Right
2drawstack%!20=(0) :
BoundTop
0drawstack%!24=0 :
Colour
;drawstack%!28=(&FFFFFF00) :
Background colour
5drawstack%!32=font% :
Font number
3drawstack%!36=size% :
Font size
5drawstack%!40=size% :
Font height
>drawstack%!44=x% :
X Coordinate of text
>drawstack%!48=y% :
Y Coordinate of text
$(drawstack%+52)=text$
drawstack%!(endpos%)=0
drawstack%!4=endpos%+4
"OS_GBPB",1,file%,drawstack%,endpos%+4,fptr%
,,,,fptr%
"THHeap_Free",memory%,,drawstack%
count%+=objlength%
"Hourglass_Percentage",(count%*100/textpos%)
_SaveDXF(filename$)
"Hourglass_On"
offset%,count%,y%
file%=
filename$
_DXF_Header
_DXF_Move(0,0)
count%=0
x%=count%
y%=(stack%!count%)
_DXF_Draw(x%,y%)
_DXF_Move(x%,y%)
1
"Hourglass_Percentage",(count%/n%)*100
_DXF_Footer
*****************************************************************
* DXF Routines *
*****************************************************************
_DXF_Header
#file%,"0"
#file%,"SECTION"
#file%,"2"
#file%,"ENTITIES"
_DXF_Move(x%,y%)
#file%,"0"
#file%,"LINE"
#file%,"8"
#file%,"0"
#file%,"10"
#file%,
(x%/10)
#file%,"20"
#file%,
(y%/10)
_DXF_Draw(x%,y%)
#file%,"11"
#file%,
(x%/10)
#file%,"21"
#file%,
(y%/10)
_DXF_Footer
#file%,"0"
#file%,"ENDSEC"
#file%,"0"
#file%,"EOF"
*****************************************************************
* Drawfile Routines *
*****************************************************************
_PathStart
"THHeap_Claim",memory%,pathsize%
,,drawstack%
'Ddrawstack%!0=(&2) :
Beginning of a Path Object
(4drawstack%!8=(0) :
Bound Left
)6drawstack%!12=(0) :
Bound Bottom
*5drawstack%!16=(0) :
Bound Right
+2drawstack%!20=(0) :
BoundTop
,>drawstack%!24=(&FFFFFFFF) :
Fill colour BBGGRRFi
-8drawstack%!28=(0) :
Outline colour
.7drawstack%!32=(0) :
Outline width
/4drawstack%!36=(&20100042) :
Path style
drawstack_pos%=36
_PathMove(x%,y%)
47drawstack%!(drawstack_pos%+4)=&2 :
Move command
5Bdrawstack%!(drawstack_pos%+8)=x% :
X Coordinate to move to
6Bdrawstack%!(drawstack_pos%+12)=y% :
Y Coordinate to move to
drawstack_pos%+=12
_PathDraw(x%,y%)
;7drawstack%!(drawstack_pos%+4)=&8 :
Draw command
<Bdrawstack%!(drawstack_pos%+8)=x% :
X Coordinate to draw to
=Bdrawstack%!(drawstack_pos%+12)=y% :
Y Coordinate to draw to
drawstack_pos%+=12
_PathEnd
B;drawstack%!(drawstack_pos%+4)=0 :
End Path command
drawstack_pos%+=8
drawstack%!4=drawstack_pos%
"OS_GBPB",1,file%,drawstack%,drawstack_pos%,fptr%
,,,,fptr%
"THHeap_Free",memory%,,drawstack%
*****************************************************************
* Graphics routines *
*****************************************************************
_Redraw
"Wimp_RedrawWindow",,Block%
more%
more%
Block%!0
Q5
main% :
textobj%>0
_RedrawText
R6
n%>0
_RedrawGraphics
S$
helpwin% :
_TextDraw
U0
"Wimp_GetRectangle",,Block%
more%
_RedrawGraphics
wposx%,wposy%,x%,count%,y%,wsizex%,scrollx%,scrolly%
Block%!0=main%
"Wimp_GetWindowOutline",,Block%
^"wposx%=Block%!4-(Block%!4
_;wposy%=Block%!16-
_TitleSize :
to allow for tool icons
wposx%,wposy%
"Wimp_GetWindowState",,Block%
wsizex%=Block%!12-Block%!4
scrollx%=Block%!20
scrolly%=Block%!24
scrollx%
4 <>0
g# scrollx%+=(4-(scrollx%
count%=scrollx%
y%=(stack%!count%)+scrolly%
wposx%+x%,wposy%-y%
o x%+=4
_RedrawText
count%,object%,textlength%,objlength%,size%,x%,y%,text$,font$
object%=1
textobj%
v#textlength%=textbuf%?(count%+2)
w#objlength%= textbuf%?(count%+1)
x#size%= textbuf%?(count%+3)
y#x%= textbuf%!(count%+4)
z#y%= textbuf%!(count%+8)
{&text$ =$(textbuf%+12+count%)
|2font$ =$(textbuf%+12+count%+textlength%)
_RelativeToMouse(x%,y%,text$,font$,size%)
count%+=objlength%
*****************************************************************
* Coordinate Calulation *
*****************************************************************
_CalculateCoords
4relative_x%=0:relative_y%=0 :
DO NOT LOCALISE!
mousex%,mousey%,window%,scrollx%,scrolly%
wminx%,wmaxy%,temp$
"Wimp_GetPointerInfo",,Block%
7mousex%=Block%!0:mousey%=Block%!4:window%=Block%!12
window%=main%
Block%!0=window%
"Wimp_GetWindowOutline",,Block%
' wminx%=Block%!4:wmaxy%=Block%!16
"Wimp_GetWindowState",,Block%
, scrollx%=Block%!20:scrolly%=Block%!24
. relative_x%=(mousex%-wminx%)+scrollx%-2
: relative_y%=(mousey%-wmaxy%)+scrolly%+2+
_TitleSize
relative_y%<0
relative_x%>0
relative_x%<n%
( relative_x%=2+
(relative_x%/4)
" temp$="("+
(relative_x%)
0 relative_y%=stack%!((relative_x%*4)-4)
8 temp$+=","+
(relative_y%)+")"
2
_IconWrite(pane%,0,temp$)
&
_IconWrite(pane%,0,"(x,y)")
*****************************************************************
* Data Edit Routines *
*****************************************************************
_ValueCurrent
#x%=(
_IconRead(edit%,1))*4)-4
_IconWrite(edit%,3,
(stack%!x%))
_ValueEdit
#x%=(
_IconRead(edit%,1))*4)-4
undobuffer%=stack%!x%
stack%!x%<>(
_IconRead(edit%,3)))
undo%!undosize%=x%
$ undo%!(undosize%+4)=stack%!x%
"THHeap_Extend",memory%,8,undo%
,,undo%
undosize%+=8
' stack%!x%=
_IconRead(edit%,3))
"Wimp_ForceRedraw",main%,x%-8,-sch%,x%+8,0
Block%!0=main%
_Redraw
_IconFlags(edit%, 5,23,
_ValueUndo
x%,y%
undosize%>0
x%=(undo%!(undosize%-8))
y%=(undo%!(undosize%-4))
stack%!x%=y%
"THHeap_Extend",memory%,-8,undo%
,,undo%
undosize%+=(-8)
undosize%<8
$
_IconFlags(edit%, 5,23,
7
This IF statement controls the undo button.
_IconWrite(edit%,3,
(stack%!x%))
"Wimp_ForceRedraw",main%,x%-8,-sch%,x%+8,0 :
cheating a bit...
_Redraw
*****************************************************************
* Drawfile Option handling routines *
*****************************************************************
_OptionsLoad
"file%=
"<Charter$Dir>.Header"
"OS_GBPB",3,file%,header%,40
,,,,fptr%
"OS_GBPB",3,file%,header2%,88,fptr%
#file%
,table%!0=0 :
font table
table%!4=&18
table%?8=1
'$(table%+9)=
_Pad("Trinity.Medium")
*****************************************************************
* Stack Handling Routines *
*****************************************************************
_StackRemove
stackmade%=
"THHeap_Free",heap%,,stack% :stackmade%=
_StackExtend(value%)
stackmade%=
stackmade%=
"THHeap_Claim",heap%,value%
,,stack%
"THHeap_Extend",heap%,value%,stack%
,,stack%
*****************************************************************
* Text handling *
*****************************************************************
_RelativeToMouse(relx%,rely%,text$,font$,size%)
wminx%,wmaxy%,scrollx%,scrolly%,mousex%,mousey%
Block%!0=main%
"Wimp_GetWindowOutline",,Block%
$wminx%=Block%!4:wmaxy%=Block%!16
"Wimp_GetWindowState",,Block%
)scrollx%=Block%!20:scrolly%=Block%!24
#mousex%=relx%+wminx%+2-scrollx%
/mousey%=rely%+wmaxy%-scrolly%-2-
_TitleSize
_FontPaint(mousex%,mousey%,text$,font$,size%)
_FontPaint(mousex%,mousey%,text$,font$,size%)
flags%,handle%
"XFont_FindFont",,font$,size%*16,size%*16
handle% ;flags%
"XWimp_SetFontColours",,0,7
"XFont_Paint",,text$,%10010,mousex%,mousey%
_TextAddToBuffer(mousex%,mousey%,text$,font$,size%)
textobj%+=1
wminx%,wmaxy%,scrollx%,scrolly%,relx%,rely%
Block%!0=main%
"Wimp_GetWindowOutline",,Block%
$wminx%=Block%!4:wmaxy%=Block%!16
"Wimp_GetWindowState",,Block%
)scrollx%=Block%!20:scrolly%=Block%!24
%relx%=(mousex%-wminx%)+scrollx%-2
2rely%=(mousey%-wmaxy%)+scrolly%+2+
_TitleSize
)fontblocksize%=12+
(font$)+
(text$)+2
"THHeap_Extend",memory%,fontblocksize%,textbuf%
,,textbuf%
#textbuf%?(textpos%+0)=textobj%
2textbuf%?(textpos%+1)=12+
(text$)+1+
(font$)+1
$textbuf%?(textpos%+2)=
(text$)+1
textbuf%?(textpos%+3)=size%
Ftextbuf%!(textpos%+4)=relx% :
needs a word, as likely to be >255
Ftextbuf%!(textpos%+8)=rely% :
needs a word, as likely to be >255
:$(textbuf%+textpos%+12)=text$ :
text$, &0D terminated
!F$(textbuf%+textpos%+12+
(text$)+1)=font$ :
font$, &0D terminated
textpos%+=fontblocksize%
_FontPaint(mousex%,mousey%,text$,font$,size%)
_TextPlace(mousex%,mousey%)
text$
text$=
_IconRead(text%,1)
(text$)>0
+F
_TextAddToBuffer(mousex%,mousey%,text$,currentfont$,fontsize%)
notext%=
./
"MenuUtil_Fade",menu_undo%,notext%
notext%=
_TextUndoLast
count%,object%,obj%
textobj%>0
object%=1
textobj%
8# obj%= textbuf%?(count%+1)
count%+=obj%
count%-=obj%
Block%!0=main%
><
"THHeap_Extend",memory%,-obj%,textbuf%
,,textbuf%
textobj%-=1
textpos%-=obj%
_Redraw
textobj%=0
notext%=
notext%=
"MenuUtil_Fade",menu_undo%,notext%
_TextToggle
Block%!0=main%
"Wimp_GetWindowState",,Block%
"Wimp_OpenWindow",,Block%
textopen%
_Window_OpenMany
N"
_Window_Close(text%)
_IconFlags(toolbox%, 1,22,textopen%)
_IconFlags(toolbox%, 0,22,(textopen%
-1))
*****************************************************************
* Messages *
*****************************************************************
_Messages
msgfile$,held%,msgbuffersize%,msgbuffer%
Z%msgfile$="<Charter$Dir>.Messages"
"MessageTrans_FileInfo",,msgfile$
held%,,msgbuffersize%
held%
]7 msgbuffer%=0 :
bit 0 set if held in memory
_>
"THHeap_Claim",memory%,msgbuffersize%
,,msgbuffer%
"THHeap_Claim",memory%,(17+
(msgfile$))
,,msg%
$(msg%+16)=msgfile$
"MessageTrans_OpenFile",msg%,msg%+16,msgbuffer%
_Lookup(token$)
resultstring%
"MessageTrans_Lookup",msg%,token$,0
,,resultstring%
_ConvertTokenToString(resultstring%)
_LookupString(token$,string$)
resultstring%
"MessageTrans_Lookup",msg%,token$,Buffer%,256,string$
,,resultstring%
_ConvertTokenToString(resultstring%)
_ConvertTokenToString(string%)
pointer%,result$
pointer%=0
(string%?pointer%>=32)
(pointer%<255)
t# result$+=
(string%?pointer%)
pointer%+=1
=result$
_TextLoad
file$
{$file$="<Charter$Dir>."+helpfile$
"OS_File",5,file$
,,,,origlength%
"THHeap_Claim",memory%,origlength%
,,origtext%
"OS_File",255,file$,origtext%,0
"THHeap_Claim",memory%,origlength%+maxlines%
,,displaytext%
"THHeap_Claim",memory%,4*maxlines%
,,textindx%
_TextSortOut
_FontFind(font$,sizex%,sizey%)
result%,flags%
"XFont_FindFont",,font$,sizex%*16,sizey%*16,0,0
result%;flags%
(flags%
result%=
=result%
_TextDraw
!Block%=helpwin%
"Wimp_GetWindowState",,Block%
wx%=Block%!4-Block%!20
wy%=Block%!16-Block%!24
,font%=
_FontFind("Trinity.Medium",12,12)
0 font%=
_FontFind("Trinity.Medium",12,12)
%
"Wimp_SetFontColours",,0,7
1 first%=(wy%-Block%!16-margin%)
spacing%
/ last%=(wy%-Block%!8-margin%)
spacing%
first%<0 first%=0
&
last%>=lines% last%=lines%-1
i%=first%
last%
Z
"Font_Paint",,displaytext%+textindx%!(4*i%),&10,wx%+32,wy%-32-spacing%*(i%+1)
_TextSortOut
lines%=0
spacing%=12*3
margin%=32
ptr%=0:lastptr%=0
s$="":w$=""
,font%=
_FontFind("Trinity.Medium",12,12)
font%>=0
"Font_Converttopoints",,textwidth%,0
,width%
lines%<maxlines%
ptr%<origlength%
newline%=
c%=origtext%?ptr%
c%<32
&
w$<>""
c%<>13
newline%=
w$+=
c%=32
N
"Font_StringWidth",,s$+w$,&FFFFFFF,&FFFFFFF,-1,
,,xsize%
xsize%>width%
newline%=
s$+=w$
w$=""
ptr%=origlength%-1
newline%=
newline%
N
"Font_StringWidth",,s$+w$,&FFFFFFF,&FFFFFFF,-1,
,,xsize%
'
xsize%<=width%
s$+=w$:w$=""
# $(displaytext%+lastptr%)=s$
& displaytext%?(lastptr%+
s$)=0
% textindx%!(4*lines%)=lastptr%
lines%+=1
lastptr%+=
s$+1
s$=w$
w$=""
ptr%+=1
_Window_Resize(helpwin%,0,(-64-spacing%*lines%),1000,0)