"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "usr/xb-6.2.3/demo/ademo.x" of archive xbasic-6.2.3-linux-i386.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 '
    2 '
    3 ' ####################
    4 ' #####  PROLOG  #####
    5 ' ####################
    6 '
    7 PROGRAM	"ademo"
    8 VERSION	"0.0016"
    9 '
   10 IMPORT	"xst"		' Standard
   11 IMPORT	"xma"		' Mathematics
   12 IMPORT	"xgr"		' GraphicsDesigner
   13 IMPORT	"xui"		' GuiDesigner
   14 '
   15 DECLARE  FUNCTION  Entry         ()
   16 INTERNAL FUNCTION  InitGui       ()
   17 INTERNAL FUNCTION  InitProgram   ()
   18 INTERNAL FUNCTION  CreateWindows ()
   19 INTERNAL FUNCTION  InitWindows   ()
   20 INTERNAL FUNCTION  Circle        (grid, message, v0, v1, v2, v3, r0, ANY)
   21 INTERNAL FUNCTION  CircleCode    (grid, message, v0, v1, v2, v3, r0, ANY)
   22 INTERNAL FUNCTION  Math          (grid, message, v0, v1, v2, v3, r0, ANY)
   23 INTERNAL FUNCTION  MathCode      (grid, message, v0, v1, v2, v3, kid, ANY)
   24 INTERNAL FUNCTION  Control       (grid, message, v0, v1, v2, v3, r0, ANY)
   25 INTERNAL FUNCTION  ControlCode   (grid, message, v0, v1, v2, v3, kid, ANY)
   26 '
   27 '
   28 ' ######################
   29 ' #####  Entry ()  #####
   30 ' ######################
   31 '
   32 FUNCTION  Entry ()
   33 	SHARED  terminateProgram
   34 	SHARED	paused
   35 	SHARED  Circle
   36 	SHARED  Math
   37 '
   38 	PRINT "begin execution of ademo.x"
   39 '
   40 	InitGui ()										' initialize messages
   41 	InitProgram ()								' initialize this program
   42 	CreateWindows ()							' create main window and others
   43 	InitWindows ()								' initialize windows
   44 '
   45 ' This message loop is modified to draw the circle pattern continuously
   46 ' when no paused, but still process messages whenever they occur.
   47 '
   48 	DO														' the message loop
   49 		count = 1										' wait for 1+ messages, then process 1
   50 		IFZ paused THEN							' if circle drawing not paused
   51 			CircleCode (0, #Redraw, 0, 0, 0, 0, 0, 0)		' draw a few circles
   52 			count = 0									' avoid hang up in XgrProcessMessages()
   53 		END IF
   54 		XgrProcessMessages (count)	' process zero or one message
   55 	LOOP UNTIL terminateProgram		' and repeats until program is terminated
   56 END FUNCTION
   57 '
   58 '
   59 ' ########################
   60 ' #####  InitGui ()  #####
   61 ' ########################
   62 '
   63 ' InitGui() initializes cursor, icon, message, and display variables.
   64 ' Programs can reference these variables, but must never change them.
   65 '
   66 FUNCTION  InitGui ()
   67 '
   68 ' ***************************************
   69 ' *****  Register Standard Cursors  *****
   70 ' ***************************************
   71 '
   72 	XgrRegisterCursor (@"default",      @#cursorDefault)
   73 	XgrRegisterCursor (@"arrow",        @#cursorArrow)
   74 	XgrRegisterCursor (@"n",            @#cursorN)
   75 	XgrRegisterCursor (@"s",            @#cursorS)
   76 	XgrRegisterCursor (@"e",            @#cursorE)
   77 	XgrRegisterCursor (@"w",            @#cursorW)
   78 	XgrRegisterCursor (@"ns",           @#cursorArrowsNS)
   79 	XgrRegisterCursor (@"ns",           @#cursorArrowsSN)
   80 	XgrRegisterCursor (@"ew",           @#cursorArrowsEW)
   81 	XgrRegisterCursor (@"ew",           @#cursorArrowsWE)
   82 	XgrRegisterCursor (@"nwse",         @#cursorArrowsNWSE)
   83 	XgrRegisterCursor (@"nesw",         @#cursorArrowsNESW)
   84 	XgrRegisterCursor (@"all",          @#cursorArrowsAll)
   85 	XgrRegisterCursor (@"plus",         @#cursorPlus)
   86 	XgrRegisterCursor (@"wait",         @#cursorWait)
   87 	XgrRegisterCursor (@"insert",       @#cursorInsert)
   88 	XgrRegisterCursor (@"crosshair",    @#cursorCrosshair)
   89 	XgrRegisterCursor (@"hourglass",    @#cursorHourglass)
   90 '
   91 	#defaultCursor = #cursorDefault
   92 '
   93 '
   94 ' ********************************************
   95 ' *****  Register Standard Window Icons  *****
   96 ' ********************************************
   97 '
   98 	XgrRegisterIcon (@"hand",					@#iconHand)
   99 	XgrRegisterIcon (@"asterisk",			@#iconAsterisk)
  100 	XgrRegisterIcon (@"question",			@#iconQuestion)
  101 	XgrRegisterIcon (@"exclamation",	@#iconExclamation)
  102 	XgrRegisterIcon (@"application",	@#iconApplication)
  103 '
  104 	XgrRegisterIcon (@"hand",					@#iconStop)						' alias
  105 	XgrRegisterIcon (@"asterisk",			@#iconInformation)		' alias
  106 	XgrRegisterIcon (@"application",  @#iconBlank)					' alias
  107 '
  108 	XgrRegisterIcon (@"window",				@#iconWindow)					' custom
  109 '
  110 '
  111 ' ******************************
  112 ' *****  Register Messages *****  Create message numbers for message names
  113 ' ******************************
  114 '
  115 	XgrRegisterMessage (@"Blowback",										@#Blowback)
  116 	XgrRegisterMessage (@"Callback",										@#Callback)
  117 	XgrRegisterMessage (@"Cancel",											@#Cancel)
  118 	XgrRegisterMessage (@"Change",											@#Change)
  119 	XgrRegisterMessage (@"CloseWindow",									@#CloseWindow)
  120 	XgrRegisterMessage (@"ContextChange",								@#ContextChange)
  121 	XgrRegisterMessage (@"Create",											@#Create)
  122 	XgrRegisterMessage (@"CreateValueArray",						@#CreateValueArray)
  123 	XgrRegisterMessage (@"CreateWindow",								@#CreateWindow)
  124 	XgrRegisterMessage (@"CursorH",											@#CursorH)
  125 	XgrRegisterMessage (@"CursorV",											@#CursorV)
  126 	XgrRegisterMessage (@"Deselected",									@#Deselected)
  127 	XgrRegisterMessage (@"Destroy",											@#Destroy)
  128 	XgrRegisterMessage (@"Destroyed",										@#Destroyed)
  129 	XgrRegisterMessage (@"DestroyWindow",								@#DestroyWindow)
  130 	XgrRegisterMessage (@"Disable",											@#Disable)
  131 	XgrRegisterMessage (@"Disabled",										@#Disabled)
  132 	XgrRegisterMessage (@"Displayed",										@#Displayed)
  133 	XgrRegisterMessage (@"DisplayWindow",								@#DisplayWindow)
  134 	XgrRegisterMessage (@"Enable",											@#Enable)
  135 	XgrRegisterMessage (@"Enabled",											@#Enabled)
  136 	XgrRegisterMessage (@"Enter",												@#Enter)
  137 	XgrRegisterMessage (@"ExitMessageLoop",							@#ExitMessageLoop)
  138 	XgrRegisterMessage (@"Find",												@#Find)
  139 	XgrRegisterMessage (@"FindForward",									@#FindForward)
  140 	XgrRegisterMessage (@"FindReverse",									@#FindReverse)
  141 	XgrRegisterMessage (@"Forward",											@#Forward)
  142 	XgrRegisterMessage (@"GetAlign",										@#GetAlign)
  143 	XgrRegisterMessage (@"GetBorder",										@#GetBorder)
  144 	XgrRegisterMessage (@"GetBorderOffset",							@#GetBorderOffset)
  145 	XgrRegisterMessage (@"GetCallback",									@#GetCallback)
  146 	XgrRegisterMessage (@"GetCallbackArgs",							@#GetCallbackArgs)
  147 	XgrRegisterMessage (@"GetCan",											@#GetCan)
  148 	XgrRegisterMessage (@"GetCharacterMapArray",				@#GetCharacterMapArray)
  149 	XgrRegisterMessage (@"GetClipGrid",									@#GetClipGrid)
  150 	XgrRegisterMessage (@"GetColor",										@#GetColor)
  151 	XgrRegisterMessage (@"GetColorExtra",								@#GetColorExtra)
  152 	XgrRegisterMessage (@"GetCursor",										@#GetCursor)
  153 	XgrRegisterMessage (@"GetCursorXY",									@#GetCursorXY)
  154 	XgrRegisterMessage (@"GetDisplay",									@#GetDisplay)
  155 	XgrRegisterMessage (@"GetEnclosedGrids",						@#GetEnclosedGrids)
  156 	XgrRegisterMessage (@"GetEnclosingGrid",						@#GetEnclosingGrid)
  157 	XgrRegisterMessage (@"GetFocusColor",								@#GetFocusColor)
  158 	XgrRegisterMessage (@"GetFocusColorExtra",					@#GetFocusColorExtra)
  159 	XgrRegisterMessage (@"GetFont",											@#GetFont)
  160 	XgrRegisterMessage (@"GetFontNumber",								@#GetFontNumber)
  161 	XgrRegisterMessage (@"GetGridFunction",							@#GetGridFunction)
  162 	XgrRegisterMessage (@"GetGridFunctionName",					@#GetGridFunctionName)
  163 	XgrRegisterMessage (@"GetGridName",									@#GetGridName)
  164 	XgrRegisterMessage (@"GetGridNumber",								@#GetGridNumber)
  165 	XgrRegisterMessage (@"GetGridType",									@#GetGridType)
  166 	XgrRegisterMessage (@"GetGridTypeName",							@#GetGridTypeName)
  167 	XgrRegisterMessage (@"GetGroup",										@#GetGroup)
  168 	XgrRegisterMessage (@"GetHelp",											@#GetHelp)
  169 	XgrRegisterMessage (@"GetHelpFile",									@#GetHelpFile)
  170 	XgrRegisterMessage (@"GetHelpString",								@#GetHelpString)
  171 	XgrRegisterMessage (@"GetHelpStrings",							@#GetHelpStrings)
  172 	XgrRegisterMessage (@"GetHintString",								@#GetHintString)
  173 	XgrRegisterMessage (@"GetImage",										@#GetImage)
  174 	XgrRegisterMessage (@"GetImageCoords",							@#GetImageCoords)
  175 	XgrRegisterMessage (@"GetIndent",										@#GetIndent)
  176 	XgrRegisterMessage (@"GetInfo",											@#GetInfo)
  177 	XgrRegisterMessage (@"GetJustify",									@#GetJustify)
  178 	XgrRegisterMessage (@"GetKeyboardFocus",						@#GetKeyboardFocus)
  179 	XgrRegisterMessage (@"GetKeyboardFocusGrid",				@#GetKeyboardFocusGrid)
  180 	XgrRegisterMessage (@"GetKidNumber",								@#GetKidNumber)
  181 	XgrRegisterMessage (@"GetKids",											@#GetKids)
  182 	XgrRegisterMessage (@"GetKidArray",									@#GetKidArray)
  183 	XgrRegisterMessage (@"GetKind",											@#GetKind)
  184 	XgrRegisterMessage (@"GetMaxMinSize",								@#GetMaxMinSize)
  185 	XgrRegisterMessage (@"GetMessageFunc",							@#GetMessageFunc)
  186 	XgrRegisterMessage (@"GetMessageFuncArray",					@#GetMessageFuncArray)
  187 	XgrRegisterMessage (@"GetMessageSub",								@#GetMessageSub)
  188 	XgrRegisterMessage (@"GetMessageSubArray",					@#GetMessageSubArray)
  189 	XgrRegisterMessage (@"GetModalInfo",								@#GetModalInfo)
  190 	XgrRegisterMessage (@"GetModalWindow",							@#GetModalWindow)
  191 	XgrRegisterMessage (@"GetParent",										@#GetParent)
  192 	XgrRegisterMessage (@"GetPosition",									@#GetPosition)
  193 	XgrRegisterMessage (@"GetProtoInfo",								@#GetProtoInfo)
  194 	XgrRegisterMessage (@"GetRedrawFlags",							@#GetRedrawFlags)
  195 	XgrRegisterMessage (@"GetSize",											@#GetSize)
  196 	XgrRegisterMessage (@"GetSmallestSize",							@#GetSmallestSize)
  197 	XgrRegisterMessage (@"GetState",										@#GetState)
  198 	XgrRegisterMessage (@"GetStyle",										@#GetStyle)
  199 	XgrRegisterMessage (@"GetTabArray",									@#GetTabArray)
  200 	XgrRegisterMessage (@"GetTabWidth",									@#GetTabWidth)
  201 	XgrRegisterMessage (@"GetTextArray",								@#GetTextArray)
  202 	XgrRegisterMessage (@"GetTextArrayBounds",					@#GetTextArrayBounds)
  203 	XgrRegisterMessage (@"GetTextArrayLine",						@#GetTextArrayLine)
  204 	XgrRegisterMessage (@"GetTextArrayLines",						@#GetTextArrayLines)
  205 	XgrRegisterMessage (@"GetTextCursor",								@#GetTextCursor)
  206 	XgrRegisterMessage (@"GetTextFilename",							@#GetTextFilename)
  207 	XgrRegisterMessage (@"GetTextPosition",							@#GetTextPosition)
  208 	XgrRegisterMessage (@"GetTextSelection",						@#GetTextSelection)
  209 	XgrRegisterMessage (@"GetTextString",								@#GetTextString)
  210 	XgrRegisterMessage (@"GetTextStrings",							@#GetTextStrings)
  211 	XgrRegisterMessage (@"GetTexture",									@#GetTexture)
  212 	XgrRegisterMessage (@"GetTimer",										@#GetTimer)
  213 	XgrRegisterMessage (@"GetValue",										@#GetValue)
  214 	XgrRegisterMessage (@"GetValues",										@#GetValues)
  215 	XgrRegisterMessage (@"GetValueArray",								@#GetValueArray)
  216 	XgrRegisterMessage (@"GetWindow",										@#GetWindow)
  217 	XgrRegisterMessage (@"GetWindowFunction",						@#GetWindowFunction)
  218 	XgrRegisterMessage (@"GetWindowGrid",								@#GetWindowGrid)
  219 	XgrRegisterMessage (@"GetWindowIcon",								@#GetWindowIcon)
  220 	XgrRegisterMessage (@"GetWindowSize",								@#GetWindowSize)
  221 	XgrRegisterMessage (@"GetWindowTitle",							@#GetWindowTitle)
  222 	XgrRegisterMessage (@"GotKeyboardFocus",						@#GotKeyboardFocus)
  223 	XgrRegisterMessage (@"GrabArray",										@#GrabArray)
  224 	XgrRegisterMessage (@"GrabTextArray",								@#GrabTextArray)
  225 	XgrRegisterMessage (@"GrabTextString",							@#GrabTextString)
  226 	XgrRegisterMessage (@"GrabValueArray",							@#GrabValueArray)
  227 	XgrRegisterMessage (@"Help",												@#Help)
  228 	XgrRegisterMessage (@"Hidden",											@#Hidden)
  229 	XgrRegisterMessage (@"HideTextCursor",							@#HideTextCursor)
  230 	XgrRegisterMessage (@"HideWindow",									@#HideWindow)
  231 	XgrRegisterMessage (@"Initialize",									@#Initialize)
  232 	XgrRegisterMessage (@"Initialized",									@#Initialized)
  233 	XgrRegisterMessage (@"Inline",											@#Inline)
  234 	XgrRegisterMessage (@"InquireText",									@#InquireText)
  235 	XgrRegisterMessage (@"KeyboardFocusBackward",				@#KeyboardFocusBackward)
  236 	XgrRegisterMessage (@"KeyboardFocusForward",				@#KeyboardFocusForward)
  237 	XgrRegisterMessage (@"KeyDown",											@#KeyDown)
  238 	XgrRegisterMessage (@"KeyUp",												@#KeyUp)
  239 	XgrRegisterMessage (@"LostKeyboardFocus",						@#LostKeyboardFocus)
  240 	XgrRegisterMessage (@"LostTextSelection",						@#LostTextSelection)
  241 	XgrRegisterMessage (@"Maximized",										@#Maximized)
  242 	XgrRegisterMessage (@"MaximizeWindow",							@#MaximizeWindow)
  243 	XgrRegisterMessage (@"Maximum",											@#Maximum)
  244 	XgrRegisterMessage (@"Minimized",										@#Minimized)
  245 	XgrRegisterMessage (@"MinimizeWindow",							@#MinimizeWindow)
  246 	XgrRegisterMessage (@"Minimum",											@#Minimum)
  247 	XgrRegisterMessage (@"MonitorContext",							@#MonitorContext)
  248 	XgrRegisterMessage (@"MonitorHelp",									@#MonitorHelp)
  249 	XgrRegisterMessage (@"MonitorKeyboard",							@#MonitorKeyboard)
  250 	XgrRegisterMessage (@"MonitorMouse",								@#MonitorMouse)
  251 	XgrRegisterMessage (@"MouseDown",										@#MouseDown)
  252 	XgrRegisterMessage (@"MouseDrag",										@#MouseDrag)
  253 	XgrRegisterMessage (@"MouseEnter",									@#MouseEnter)
  254 	XgrRegisterMessage (@"MouseExit",										@#MouseExit)
  255 	XgrRegisterMessage (@"MouseMove",										@#MouseMove)
  256 	XgrRegisterMessage (@"MouseUp",											@#MouseUp)
  257 	XgrRegisterMessage (@"MouseWheel",									@#MouseWheel)
  258 	XgrRegisterMessage (@"MuchLess",										@#MuchLess)
  259 	XgrRegisterMessage (@"MuchMore",										@#MuchMore)
  260 	XgrRegisterMessage (@"OneLess",											@#OneLess)
  261 	XgrRegisterMessage (@"OneMore",											@#OneMore)
  262 	XgrRegisterMessage (@"PokeArray",										@#PokeArray)
  263 	XgrRegisterMessage (@"PokeTextArray",								@#PokeTextArray)
  264 	XgrRegisterMessage (@"PokeTextString",							@#PokeTextString)
  265 	XgrRegisterMessage (@"PokeValueArray",							@#PokeValueArray)
  266 	XgrRegisterMessage (@"Print",												@#Print)
  267 	XgrRegisterMessage (@"Redraw",											@#Redraw)
  268 	XgrRegisterMessage (@"RedrawGrid",									@#RedrawGrid)
  269 	XgrRegisterMessage (@"RedrawLines",									@#RedrawLines)
  270 	XgrRegisterMessage (@"RedrawText",									@#RedrawText)
  271 	XgrRegisterMessage (@"RedrawWindow",								@#RedrawWindow)
  272 	XgrRegisterMessage (@"Replace",											@#Replace)
  273 	XgrRegisterMessage (@"ReplaceForward",							@#ReplaceForward)
  274 	XgrRegisterMessage (@"ReplaceReverse",							@#ReplaceReverse)
  275 	XgrRegisterMessage (@"Reset",												@#Reset)
  276 	XgrRegisterMessage (@"Resize",											@#Resize)
  277 	XgrRegisterMessage (@"Resized",											@#Resized)
  278 	XgrRegisterMessage (@"ResizeNot",										@#ResizeNot)
  279 	XgrRegisterMessage (@"ResizeWindow",								@#ResizeWindow)
  280 	XgrRegisterMessage (@"ResizeWindowToGrid",					@#ResizeWindowToGrid)
  281 	XgrRegisterMessage (@"Resized",											@#Resized)
  282 	XgrRegisterMessage (@"Reverse",											@#Reverse)
  283 	XgrRegisterMessage (@"ScrollH",											@#ScrollH)
  284 	XgrRegisterMessage (@"ScrollV",											@#ScrollV)
  285 	XgrRegisterMessage (@"Select",											@#Select)
  286 	XgrRegisterMessage (@"Selected",										@#Selected)
  287 	XgrRegisterMessage (@"Selection",										@#Selection)
  288 	XgrRegisterMessage (@"SelectWindow",								@#SelectWindow)
  289 	XgrRegisterMessage (@"SetAlign",										@#SetAlign)
  290 	XgrRegisterMessage (@"SetBorder",										@#SetBorder)
  291 	XgrRegisterMessage (@"SetBorderOffset",							@#SetBorderOffset)
  292 	XgrRegisterMessage (@"SetCallback",									@#SetCallback)
  293 	XgrRegisterMessage (@"SetCan",											@#SetCan)
  294 	XgrRegisterMessage (@"SetCharacterMapArray",				@#SetCharacterMapArray)
  295 	XgrRegisterMessage (@"SetClipGrid",									@#SetClipGrid)
  296 	XgrRegisterMessage (@"SetColor",										@#SetColor)
  297 	XgrRegisterMessage (@"SetColorAll",									@#SetColorAll)
  298 	XgrRegisterMessage (@"SetColorExtra",								@#SetColorExtra)
  299 	XgrRegisterMessage (@"SetColorExtraAll",						@#SetColorExtraAll)
  300 	XgrRegisterMessage (@"SetCursor",										@#SetCursor)
  301 	XgrRegisterMessage (@"SetCursorXY",									@#SetCursorXY)
  302 	XgrRegisterMessage (@"SetDisplay",									@#SetDisplay)
  303 	XgrRegisterMessage (@"SetFocusColor",								@#SetFocusColor)
  304 	XgrRegisterMessage (@"SetFocusColorExtra",					@#SetFocusColorExtra)
  305 	XgrRegisterMessage (@"SetFont",											@#SetFont)
  306 	XgrRegisterMessage (@"SetFontNumber",								@#SetFontNumber)
  307 	XgrRegisterMessage (@"SetGridFunction",							@#SetGridFunction)
  308 	XgrRegisterMessage (@"SetGridFunctionName",					@#SetGridFunctionName)
  309 	XgrRegisterMessage (@"SetGridName",									@#SetGridName)
  310 	XgrRegisterMessage (@"SetGridType",									@#SetGridType)
  311 	XgrRegisterMessage (@"SetGridTypeName",							@#SetGridTypeName)
  312 	XgrRegisterMessage (@"SetGroup",										@#SetGroup)
  313 	XgrRegisterMessage (@"SetHelp",											@#SetHelp)
  314 	XgrRegisterMessage (@"SetHelpFile",									@#SetHelpFile)
  315 	XgrRegisterMessage (@"SetHelpString",								@#SetHelpString)
  316 	XgrRegisterMessage (@"SetHelpStrings",							@#SetHelpStrings)
  317 	XgrRegisterMessage (@"SetHintString",								@#SetHintString)
  318 	XgrRegisterMessage (@"SetImage",										@#SetImage)
  319 	XgrRegisterMessage (@"SetImageCoords",							@#SetImageCoords)
  320 	XgrRegisterMessage (@"SetIndent",										@#SetIndent)
  321 	XgrRegisterMessage (@"SetInfo",											@#SetInfo)
  322 	XgrRegisterMessage (@"SetJustify",									@#SetJustify)
  323 	XgrRegisterMessage (@"SetKeyboardFocus",						@#SetKeyboardFocus)
  324 	XgrRegisterMessage (@"SetKeyboardFocusGrid",				@#SetKeyboardFocusGrid)
  325 	XgrRegisterMessage (@"SetMaxMinSize",								@#SetMaxMinSize)
  326 	XgrRegisterMessage (@"SetMessageFunc",							@#SetMessageFunc)
  327 	XgrRegisterMessage (@"SetMessageFuncArray",					@#SetMessageFuncArray)
  328 	XgrRegisterMessage (@"SetMessageSub",								@#SetMessageSub)
  329 	XgrRegisterMessage (@"SetMessageSubArray",					@#SetMessageSubArray)
  330 	XgrRegisterMessage (@"SetModalWindow",							@#SetModalWindow)
  331 	XgrRegisterMessage (@"SetParent",										@#SetParent)
  332 	XgrRegisterMessage (@"SetPosition",									@#SetPosition)
  333 	XgrRegisterMessage (@"SetRedrawFlags",							@#SetRedrawFlags)
  334 	XgrRegisterMessage (@"SetSize",											@#SetSize)
  335 	XgrRegisterMessage (@"SetState",										@#SetState)
  336 	XgrRegisterMessage (@"SetStyle",										@#SetStyle)
  337 	XgrRegisterMessage (@"SetTabArray",									@#SetTabArray)
  338 	XgrRegisterMessage (@"SetTabWidth",									@#SetTabWidth)
  339 	XgrRegisterMessage (@"SetTextArray",								@#SetTextArray)
  340 	XgrRegisterMessage (@"SetTextArrayLine",						@#SetTextArrayLine)
  341 	XgrRegisterMessage (@"SetTextArrayLines",						@#SetTextArrayLines)
  342 	XgrRegisterMessage (@"SetTextCursor",								@#SetTextCursor)
  343 	XgrRegisterMessage (@"SetTextFilename",							@#SetTextFilename)
  344 	XgrRegisterMessage (@"SetTextSelection",						@#SetTextSelection)
  345 	XgrRegisterMessage (@"SetTextString",								@#SetTextString)
  346 	XgrRegisterMessage (@"SetTextStrings",							@#SetTextStrings)
  347 	XgrRegisterMessage (@"SetTexture",									@#SetTexture)
  348 	XgrRegisterMessage (@"SetTimer",										@#SetTimer)
  349 	XgrRegisterMessage (@"SetValue",										@#SetValue)
  350 	XgrRegisterMessage (@"SetValues",										@#SetValues)
  351 	XgrRegisterMessage (@"SetValueArray",								@#SetValueArray)
  352 	XgrRegisterMessage (@"SetWindowFunction",						@#SetWindowFunction)
  353 	XgrRegisterMessage (@"SetWindowIcon",								@#SetWindowIcon)
  354 	XgrRegisterMessage (@"SetWindowTitle",							@#SetWindowTitle)
  355 	XgrRegisterMessage (@"ShowTextCursor",							@#ShowTextCursor)
  356 	XgrRegisterMessage (@"ShowWindow",									@#ShowWindow)
  357 	XgrRegisterMessage (@"SomeLess",										@#SomeLess)
  358 	XgrRegisterMessage (@"SomeMore",										@#SomeMore)
  359 	XgrRegisterMessage (@"StartTimer",									@#StartTimer)
  360 	XgrRegisterMessage (@"SystemMessage",								@#SystemMessage)
  361 	XgrRegisterMessage (@"TextDelete",									@#TextDelete)
  362 	XgrRegisterMessage (@"TextEvent",										@#TextEvent)
  363 	XgrRegisterMessage (@"TextInsert",									@#TextInsert)
  364 	XgrRegisterMessage (@"TextModified",								@#TextModified)
  365 	XgrRegisterMessage (@"TextReplace",									@#TextReplace)
  366 	XgrRegisterMessage (@"TimeOut",											@#TimeOut)
  367 	XgrRegisterMessage (@"Update",											@#Update)
  368 	XgrRegisterMessage (@"WindowClose",									@#WindowClose)
  369 	XgrRegisterMessage (@"WindowCreate",								@#WindowCreate)
  370 	XgrRegisterMessage (@"WindowDeselected",						@#WindowDeselected)
  371 	XgrRegisterMessage (@"WindowDestroy",								@#WindowDestroy)
  372 	XgrRegisterMessage (@"WindowDestroyed",							@#WindowDestroyed)
  373 	XgrRegisterMessage (@"WindowDisplay",								@#WindowDisplay)
  374 	XgrRegisterMessage (@"WindowDisplayed",							@#WindowDisplayed)
  375 	XgrRegisterMessage (@"WindowGetDisplay",						@#WindowGetDisplay)
  376 	XgrRegisterMessage (@"WindowGetFunction",						@#WindowGetFunction)
  377 	XgrRegisterMessage (@"WindowGetIcon",								@#WindowGetIcon)
  378 	XgrRegisterMessage (@"WindowGetKeyboardFocusGrid",	@#WindowGetKeyboardFocusGrid)
  379 	XgrRegisterMessage (@"WindowGetSelectedWindow",			@#WindowGetSelectedWindow)
  380 	XgrRegisterMessage (@"WindowGetSize",								@#WindowGetSize)
  381 	XgrRegisterMessage (@"WindowGetTitle",							@#WindowGetTitle)
  382 	XgrRegisterMessage (@"WindowHelp",									@#WindowHelp)
  383 	XgrRegisterMessage (@"WindowHide",									@#WindowHide)
  384 	XgrRegisterMessage (@"WindowHidden",								@#WindowHidden)
  385 	XgrRegisterMessage (@"WindowKeyDown",								@#WindowKeyDown)
  386 	XgrRegisterMessage (@"WindowKeyUp",									@#WindowKeyUp)
  387 	XgrRegisterMessage (@"WindowMaximize",							@#WindowMaximize)
  388 	XgrRegisterMessage (@"WindowMaximized",							@#WindowMaximized)
  389 	XgrRegisterMessage (@"WindowMinimize",							@#WindowMinimize)
  390 	XgrRegisterMessage (@"WindowMinimized",							@#WindowMinimized)
  391 	XgrRegisterMessage (@"WindowMonitorContext",				@#WindowMonitorContext)
  392 	XgrRegisterMessage (@"WindowMonitorHelp",						@#WindowMonitorHelp)
  393 	XgrRegisterMessage (@"WindowMonitorKeyboard",				@#WindowMonitorKeyboard)
  394 	XgrRegisterMessage (@"WindowMonitorMouse",					@#WindowMonitorMouse)
  395 	XgrRegisterMessage (@"WindowMouseDown",							@#WindowMouseDown)
  396 	XgrRegisterMessage (@"WindowMouseDrag",							@#WindowMouseDrag)
  397 	XgrRegisterMessage (@"WindowMouseEnter",						@#WindowMouseEnter)
  398 	XgrRegisterMessage (@"WindowMouseExit",							@#WindowMouseExit)
  399 	XgrRegisterMessage (@"WindowMouseMove",							@#WindowMouseMove)
  400 	XgrRegisterMessage (@"WindowMouseUp",								@#WindowMouseUp)
  401 	XgrRegisterMessage (@"WindowMouseWheel",						@#WindowMouseWheel)
  402 	XgrRegisterMessage (@"WindowRedraw",								@#WindowRedraw)
  403 	XgrRegisterMessage (@"WindowRegister",							@#WindowRegister)
  404 	XgrRegisterMessage (@"WindowResize",								@#WindowResize)
  405 	XgrRegisterMessage (@"WindowResized",								@#WindowResized)
  406 	XgrRegisterMessage (@"WindowResizeToGrid",					@#WindowResizeToGrid)
  407 	XgrRegisterMessage (@"WindowSelect",								@#WindowSelect)
  408 	XgrRegisterMessage (@"WindowSelected",							@#WindowSelected)
  409 	XgrRegisterMessage (@"WindowSetFunction",						@#WindowSetFunction)
  410 	XgrRegisterMessage (@"WindowSetIcon",								@#WindowSetIcon)
  411 	XgrRegisterMessage (@"WindowSetKeyboardFocusGrid",	@#WindowSetKeyboardFocusGrid)
  412 	XgrRegisterMessage (@"WindowSetTitle",							@#WindowSetTitle)
  413 	XgrRegisterMessage (@"WindowShow",									@#WindowShow)
  414 	XgrRegisterMessage (@"WindowSystemMessage",					@#WindowSystemMessage)
  415 	XgrRegisterMessage (@"LastMessage",									@#LastMessage)
  416 '
  417 	XgrGetDisplaySize ("", @#displayWidth, @#displayHeight, @#windowBorderWidth, @#windowTitleHeight)
  418 END FUNCTION
  419 '
  420 '
  421 ' ############################
  422 ' #####  InitProgram ()  #####
  423 ' ############################
  424 '
  425 FUNCTION  InitProgram ()
  426 '		Initialize everything your program needs to initialize
  427 END FUNCTION
  428 '
  429 '
  430 ' ##############################
  431 ' #####  CreateWindows ()  #####
  432 ' ##############################
  433 '
  434 FUNCTION  CreateWindows ()
  435 	SHARED  Control
  436 	SHARED  Circle
  437 	SHARED	Math
  438 '
  439 	wt = $$WindowTypeResizeFrame OR $$WindowTypeSystemMenu OR $$WindowTypeTitleBar OR $$WindowTypeMinimizeBox OR $$WindowTypeMaximizeBox
  440   Control        (@Control, #CreateWindow, 0, 0, 0, 0, wt, 0)
  441   XuiSendMessage ( Control, #SetCallback, Control, &ControlCode(), -1, -1, -1, 0)
  442   XuiSendMessage ( Control, #DisplayWindow, 0, 0, 0, 0, 0, 0)
  443 	PRINT "display control window"
  444 '
  445 	wt = $$WindowTypeResizeFrame OR $$WindowTypeSystemMenu OR $$WindowTypeTitleBar OR $$WindowTypeMinimizeBox OR $$WindowTypeMaximizeBox OR $$WindowTypeCloseHide
  446 	Circle         (@Circle, #CreateWindow, 0, 0, 0, 0, wt, 0)
  447 	XuiSendMessage ( Circle, #SetCallback, Circle, &CircleCode(), -1, -1, -1, -1)
  448 	XuiSendMessage ( Circle, #DisplayWindow, 0, 0, 0, 0, 0, 0)
  449 	PRINT "display circle window"
  450 '
  451 	wt = $$WindowTypeResizeFrame OR $$WindowTypeSystemMenu OR $$WindowTypeTitleBar OR $$WindowTypeMinimizeBox OR $$WindowTypeMaximizeBox OR $$WindowTypeCloseMinimize
  452 	Math           (@Math, #CreateWindow, 0, 0, 0, 0, wt, 0)
  453 	XuiSendMessage ( Math, #SetCallback, Math, &MathCode(), -1, -1, -1, -1)
  454 	XuiSendMessage ( Math, #DisplayWindow, 0, 0, 0, 0, 0, 0)
  455 	PRINT "display math window"
  456 END FUNCTION
  457 '
  458 '
  459 ' ############################
  460 ' #####  InitWindows ()  #####
  461 ' ############################
  462 '
  463 FUNCTION  InitWindows ()
  464 	SHARED  Math
  465 '
  466 	XstGetConsoleGrid (@console)
  467 	XstGetApplicationEnvironment (@standalone, @reserved)
  468 	IF standalone THEN XuiSendMessage (console, #HideWindow, 0, 0, 0, 0, 0, 0)
  469 '
  470 	XuiSendMessage (Math, #MouseDown, 0, 0, 0, 0, 23, 0)
  471 END FUNCTION
  472 '
  473 '
  474 ' #######################
  475 ' #####  Circle ()  #####
  476 ' #######################
  477 '
  478 FUNCTION  Circle (grid, message, v0, v1, v2, v3, r0, (r1, r1$, r1[], r1$[]))
  479   STATIC	designX,  designY,  designWidth,  designHeight
  480   STATIC	SUBADDR  sub[]
  481 	STATIC	upperMessage
  482   STATIC	Circle
  483 '
  484   $Circle       =   0  ' kid   0 grid type = Circle
  485   $DrawingArea  =   1  ' kid   1 grid type = XuiArea
  486   $ClearButton  =   2  ' kid   2 grid type = XuiPushButton
  487   $PauseButton  =   3  ' kid   3 grid type = XuiPushButton
  488   $QuitButton   =   4  ' kid   4 grid type = XuiPushButton
  489   $UpperKid     =   4  ' kid maximum
  490 '
  491   IFZ sub[] THEN GOSUB Initialize
  492 ' XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  493   IF XuiProcessMessage (grid, message, @v0, @v1, @v2, @v3, @r0, @r1, Circle) THEN RETURN
  494   IF (message <= upperMessage) THEN GOSUB @sub[message]
  495   RETURN
  496 '
  497 '
  498 ' *****  Callback  *****  message = Callback : r1 = original message
  499 '
  500 SUB Callback
  501   message = r1
  502   IF (message <= upperMessage) THEN GOSUB @sub[message]
  503 END SUB
  504 '
  505 '
  506 ' *****  Create  *****  v0123 = xywh : r0 = window : r1 = parent
  507 '
  508 SUB Create
  509   IF (v0 <= 0) THEN v0 = 0
  510   IF (v1 <= 0) THEN v1 = 0
  511   IF (v2 <= 0) THEN v2 = designWidth
  512   IF (v3 <= 0) THEN v3 = designHeight
  513   XuiCreateGrid (@grid, Circle, @v0, @v1, @v2, @v3, r0, r1, &Circle())
  514   XuiSendMessage ( grid, #SetGridName, 0, 0, 0, 0, 0, @"Circle")
  515   XuiArea        (@g, #Create, 4, 4, 444, 444, r0, grid)
  516   XuiSendMessage ( g, #SetCallback, grid, &Circle(), -1, -1, $DrawingArea, grid)
  517   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"DrawingArea")
  518   XuiSendMessage ( g, #SetColor, $$Black, $$White, $$Black, $$White, 0, 0)
  519   XuiSendMessage ( g, #SetColorExtra, 37, 120, $$Black, $$White, 0, 0)
  520   XuiPushButton  (@g, #Create, 4, 448, 148, 20, r0, grid)
  521   XuiSendMessage ( g, #SetCallback, grid, &Circle(), -1, -1, $ClearButton, grid)
  522   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ClearButton")
  523   XuiSendMessage ( g, #SetColor, $$BrightGreen, $$Black, $$Black, $$White, 0, 0)
  524   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @" Clear ")
  525   XuiPushButton  (@g, #Create, 152, 448, 148, 20, r0, grid)
  526   XuiSendMessage ( g, #SetCallback, grid, &Circle(), -1, -1, $PauseButton, grid)
  527   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"PauseButton")
  528   XuiSendMessage ( g, #SetColor, 110, $$Black, $$Black, $$White, 0, 0)
  529   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @" Pause ")
  530   XuiPushButton  (@g, #Create, 300, 448, 148, 20, r0, grid)
  531   XuiSendMessage ( g, #SetCallback, grid, &Circle(), -1, -1, $QuitButton, grid)
  532   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"QuitButton")
  533   XuiSendMessage ( g, #SetColor, 102, $$Black, $$Black, $$White, 0, 0)
  534   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @" Quit ")
  535   GOSUB Resize
  536 END SUB
  537 '
  538 '
  539 ' *****  CreateWindow  *****  v0123 = xywh : r0 = windowType : r1$ = display$
  540 '
  541 SUB CreateWindow
  542   IF (v0 =  0) THEN v0 = designX
  543   IF (v1 =  0) THEN v1 = designY
  544   IF (v2 <= 0) THEN v2 = designWidth
  545   IF (v3 <= 0) THEN v3 = designHeight
  546   XuiWindow (@window, #WindowCreate, v0, v1, v2, v3, r0, @r1$)
  547   v0 = 0 : v1 = 0 : r0 = window : ATTACH r1$ TO display$
  548   GOSUB Create
  549 	r1 = 0 : ATTACH display$ TO r1$
  550   XuiWindow (window, #WindowRegister, grid, -1, v2, v3, @r0, @"Circle")
  551 END SUB
  552 '
  553 '
  554 ' *****  DesignSize  *****
  555 '
  556 SUB DesignSize
  557   v0 = designX : v1 = designY : v2 = designWidth : v3 = designHeight
  558 END SUB
  559 '
  560 '
  561 ' *****  GetSmallestSize  *****
  562 '
  563 SUB GetSmallestSize
  564 	v2 = 100
  565 	v3 = 120
  566 	XuiGetBorder (grid, #GetBorder, 0, 0, 0, 0, 0, @bw)
  567 	FOR i = 2 TO 4
  568 		XuiSendMessage (grid, #GetSmallestSize, 0, 0, @ww, @hh, i, 0)
  569 		w = MAX (w, ww) : h = MAX (h, hh)
  570 	NEXT i
  571 	w = w + 4 AND -4
  572 	h = h + 4 AND -4
  573 	innerWidth = w + w + w
  574 	innerHeight = innerWidth + h
  575 	totalWidth = bw + bw + innerWidth
  576 	totalHeight = bw + bw + innerHeight
  577 	v2 = totalWidth
  578 	v3 = totalHeight
  579 END SUB
  580 '
  581 '
  582 ' *****  Resize  *****
  583 '
  584 SUB Resize
  585 	v2Entry = v2
  586 	v3Entry = v3
  587 	GOSUB GetSmallestSize
  588 	v2 = MAX (v2, v2Entry)
  589 	v3 = MAX (v3, v3Entry)
  590 '	IF (v2 > (v3 - h)) THEN v2 = v3 - h
  591 '	IF (v3 > (v2 + h)) THEN v3 = v2 + h
  592 '
  593 	XuiPositionGrid (grid, @v0, @v1, @v2, @v3)
  594 	innerWidth = v2 - bw - bw
  595 	innerHeight = v3 - bw - bw
  596 	gw			= innerWidth
  597 	gh			= innerHeight - h
  598 	bw0			= innerWidth / 3
  599 	bw1			= bw0
  600 	bw2			= innerWidth - bw1 - bw0
  601 	bx0			= bw
  602 	bx1			= bx0 + bw0
  603 	bx2			= bx1 + bw1
  604 	by			= v3-h-bw
  605 '
  606 	XuiSendMessage (grid, #Resize,  bw, bw,  gw, gh, 1, 0)
  607 	XuiSendMessage (grid, #Resize, bx0, by, bw0,  h, 2, 0)
  608 	XuiSendMessage (grid, #Resize, bx1, by, bw1,  h, 3, 0)
  609 	XuiSendMessage (grid, #Resize, bx2, by, bw2,  h, 4, 0)
  610 	XuiSendMessage (grid, #ResizeWindowToGrid, 0, 0, 0, 0, 0, 0)
  611 	XuiGetSize (grid, #GetSize, 0, 0, @width, @height, 0, 0)
  612 	XuiCallback (grid, #Resized, 0, 0, width, height, 0, 0)
  613 END SUB
  614 '
  615 '
  616 ' *****  Initialize  *****
  617 '
  618 SUB Initialize
  619   XuiGetDefaultMessageFuncArray (@func[])
  620   XgrMessageNameToNumber (@"LastMessage", @upperMessage)
  621 '
  622   func[#Callback]           = &XuiCallback()
  623   func[#Resize]             = &XuiResizeNot()
  624   func[#Selection]          = &XuiCallback()
  625 	func[#GetSmallestSize]    = 0
  626 	func[#Resize]             = 0
  627 '
  628   DIM sub[upperMessage]
  629   sub[#Create]              = SUBADDRESS (Create)
  630   sub[#CreateWindow]        = SUBADDRESS (CreateWindow)
  631   sub[#GetSmallestSize]     = SUBADDRESS (GetSmallestSize)
  632   sub[#Resize]              = SUBADDRESS (Resize)
  633 '
  634 	IF func[0] THEN PRINT "Circle(): Initialize: Error::: (Undefined Message)"
  635 	IF sub[0] THEN PRINT "Circle(): Initialize: Error::: (Undefined Message)"
  636   XuiRegisterGridType (@Circle, "Circle", &Circle(), @func[], @sub[])
  637 '
  638   designX = 4
  639   designY = 293
  640   designWidth = 452
  641   designHeight = 472
  642 '
  643 	gridType = Circle
  644 	XuiSetGridTypeValue (gridType, @"x",           designX)
  645 	XuiSetGridTypeValue (gridType, @"y",           designY)
  646 	XuiSetGridTypeValue (gridType, @"width",       designWidth)
  647 	XuiSetGridTypeValue (gridType, @"height",      designHeight)
  648 	XuiSetGridTypeValue (gridType, @"border",      $$BorderFrame)
  649 	XuiSetGridTypeValue (gridType, @"can",         $$Focus OR $$Respond OR $$Callback)
  650   IFZ message THEN RETURN
  651 END SUB
  652 END FUNCTION
  653 '
  654 '
  655 ' ###########################
  656 ' #####  CircleCode ()  #####
  657 ' ###########################
  658 '
  659 FUNCTION  CircleCode (grid, message, v0, v1, v2, v3, r0, r1)
  660 	SHARED	Circle,  CircleGrid
  661 	SHARED	paused,  circleWidth,  circleHeight
  662 	STATIC	entry,  color,  dx,  dy,  half,  rad,  jjj
  663 	STATIC	s1#,  s2#,  a1#,  a2#
  664 '
  665   $Circle       =   0  ' kid   0 grid type = Circle
  666   $DrawingArea  =   1  ' kid   1 grid type = XuiArea
  667   $ClearButton  =   2  ' kid   2 grid type = XuiPushButton
  668   $PauseButton  =   3  ' kid   3 grid type = XuiPushButton
  669   $QuitButton   =   4  ' kid   4 grid type = XuiPushButton
  670   $UpperKid     =   4  ' kid maximum
  671 '
  672 '	XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  673 	IFZ entry THEN entry = $$TRUE : GOSUB Resized
  674 	IF (message = #Callback) THEN message = r1
  675 '
  676 	SELECT CASE message
  677 		CASE #Redraw			:	GOSUB Redraw
  678 		CASE #Resized			:	GOSUB Resized
  679 		CASE #Selection		:	GOSUB Selection
  680 		CASE #CloseWindow	:	GOSUB CloseWindow
  681 	END SELECT
  682 	RETURN
  683 '
  684 '
  685 ' *****  CloseWindow  *****
  686 '
  687 SUB CloseWindow
  688 	PRINT "CircleCode() : windowType handles CloseWindow from system menu"
  689 END SUB
  690 '
  691 '
  692 ' *****  Selection  *****
  693 '
  694 SUB Selection
  695 	SELECT CASE r0
  696 		CASE $ClearButton	: XgrClearGrid (CircleGrid, -1)
  697 		CASE $PauseButton	: paused = NOT paused
  698 		CASE $QuitButton	: QUIT (0)
  699 	END SELECT
  700 END SUB
  701 '
  702 '
  703 ' *********************
  704 ' *****  Resized  *****  Callbacks from Circle() resize routine
  705 ' *********************
  706 '
  707 SUB Resized
  708 	entry = $$TRUE
  709 	XuiSendMessage (Circle, #GetKidArray, 0, 0, 0, 0, 0, @kid[])
  710 	XuiSendMessage (Circle, #GetSize, 0, 0, @circleWidth, @circleHeight, 1, 0)
  711 	CircleGrid = kid[1]
  712 	s1#		= $$PI / 256#
  713 	s2#		= 4.9# * s1#
  714 	a1#		= 0#
  715 	a2#		= $$PI / 4#
  716 	dx		= circleWidth >> 1
  717 	dy		= circleHeight >> 1
  718 	rad		= MIN (circleWidth, circleHeight) >> 1
  719 	rad		= rad - 6
  720 	color = 0
  721 	XgrClearGrid (CircleGrid, -1)
  722 END SUB
  723 '
  724 '
  725 ' ********************
  726 ' *****  Redraw  *****  Messages from Entry ()
  727 ' ********************
  728 '
  729 SUB Redraw
  730 	INC jjj
  731 	IF (jjj > 100) THEN jjj = 0
  732 	IF (jjj < 50) THEN XgrClearGrid (CircleGrid, -1)		' comment out or in for variety
  733 	FOR i = 0 TO 99
  734 		GOSUB Circle
  735 	NEXT i
  736 	INC color
  737 END SUB
  738 '
  739 '
  740 ' ********************
  741 ' *****  Circle  *****  Drawing subroutine
  742 ' ********************
  743 '
  744 SUB Circle
  745 	IF (a1# >= $$TWOPI) THEN
  746 		a1# = a1# - $$TWOPI
  747 		color = (color + 3)
  748 		IF (color > 124) THEN color = color - 124
  749 	END IF
  750 	IF (a2# >= $$TWOPI) THEN
  751 		a2# = a2# - $$TWOPI
  752 		INC i
  753 	END IF
  754 	IFZ color THEN INC color
  755 	p1x	= SIN (a1#) * rad + dx
  756 	p1y	= COS (a1#) * rad + dy
  757 	p2x	= SIN (a2#) * rad + dx
  758 	p2y	= COS (a2#) * rad + dy
  759 	XgrDrawLine (CircleGrid, color, p1x, p1y, p2x, p2y)
  760 	a1#	= a1# + s1#
  761 	a2#	= a2# + s2#
  762 	s2# = 1.0002# * s2#
  763 	IF (s2# > $$TWOPI) THEN s2# = s2# - $$TWOPI
  764 END SUB
  765 END FUNCTION
  766 '
  767 '
  768 ' #####################
  769 ' #####  Math ()  #####
  770 ' #####################
  771 '
  772 FUNCTION  Math (grid, message, v0, v1, v2, v3, r0, (r1, r1$, r1[], r1$[]))
  773 	STATIC	designX,  designY,  designWidth,  designHeight
  774   STATIC	SUBADDR  sub[]
  775   STATIC	upperMessage
  776   STATIC	Math
  777 '
  778   $Math     =  0  ' kid  0 grid type = Math
  779   $SIN      =  1  ' kid  1 grid type = XuiRadioButton
  780   $ASIN     =  2  ' kid  2 grid type = XuiRadioButton
  781   $Graphic  =  3  ' kid  3 grid type = XuiLabel
  782   $Graph    =  4  ' kid  4 grid type = XuiLabel
  783   $COS      =  5  ' kid  5 grid type = XuiRadioButton
  784   $ACOS     =  6  ' kid  6 grid type = XuiRadioButton
  785   $TAN      =  7  ' kid  7 grid type = XuiRadioButton
  786   $ATAN     =  8  ' kid  8 grid type = XuiRadioButton
  787   $COT      =  9  ' kid  9 grid type = XuiRadioButton
  788   $ACOT     = 10  ' kid 10 grid type = XuiRadioButton
  789   $SEC      = 11  ' kid 11 grid type = XuiRadioButton
  790   $ASEC     = 12  ' kid 12 grid type = XuiRadioButton
  791   $CSC      = 13  ' kid 13 grid type = XuiRadioButton
  792   $ACSC     = 14  ' kid 14 grid type = XuiRadioButton
  793   $SINH     = 15  ' kid 15 grid type = XuiRadioButton
  794   $ASINH    = 16  ' kid 16 grid type = XuiRadioButton
  795   $COSH     = 17  ' kid 17 grid type = XuiRadioButton
  796   $ACOSH    = 18  ' kid 18 grid type = XuiRadioButton
  797   $TANH     = 19  ' kid 19 grid type = XuiRadioButton
  798   $ATANH    = 20  ' kid 20 grid type = XuiRadioButton
  799   $COTH     = 21  ' kid 21 grid type = XuiRadioButton
  800   $ACOTH    = 22  ' kid 22 grid type = XuiRadioButton
  801   $SECH     = 23  ' kid 23 grid type = XuiRadioButton
  802   $ASECH    = 24  ' kid 24 grid type = XuiRadioButton
  803   $CSCH     = 25  ' kid 25 grid type = XuiRadioButton
  804   $ACSCH    = 26  ' kid 26 grid type = XuiRadioButton
  805   $SQRT     = 27  ' kid 27 grid type = XuiRadioButton
  806   $POWER    = 28  ' kid 28 grid type = XuiRadioButton
  807   $Range    = 29  ' kid 29 grid type = XuiLabel
  808   $LOG      = 30  ' kid 30 grid type = XuiRadioButton
  809   $EXP      = 31  ' kid 31 grid type = XuiRadioButton
  810   $Maximum  = 32  ' kid 32 grid type = XuiLabel
  811   $LOG10    = 33  ' kid 33 grid type = XuiRadioButton
  812   $EXP10    = 34  ' kid 34 grid type = XuiRadioButton
  813   $Minimum  = 35  ' kid 35 grid type = XuiLabel
  814   $CLEAR    = 36  ' kid 36 grid type = XuiRadioButton
  815   $QUIT     = 37  ' kid 37 grid type = XuiRadioButton
  816   $Comment  = 38  ' kid 38 grid type = XuiLabel
  817 '
  818   IFZ sub[] THEN GOSUB Initialize
  819 '	XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
  820   IF XuiProcessMessage (grid, message, @v0, @v1, @v2, @v3, @r0, @r1, Math) THEN RETURN
  821   IF (message <= upperMessage) THEN GOSUB @sub[message]
  822   RETURN
  823 '
  824 '
  825 ' *****  Callback  *****  message = Callback : r1 = original message
  826 '
  827 SUB Callback
  828   message = r1
  829   IF (message <= upperMessage) THEN GOSUB @sub[message]
  830 END SUB
  831 '
  832 '
  833 ' *****  Create  *****  v0123 = xywh : r0 = window : r1 = parent
  834 '
  835 SUB Create
  836   IF (v0 <= 0) THEN v0 = 0
  837   IF (v1 <= 0) THEN v1 = 0
  838   IF (v2 <= 0) THEN v2 = designWidth
  839   IF (v3 <= 0) THEN v3 = designHeight
  840   XuiCreateGrid  (@grid, Math, @v0, @v1, @v2, @v3, r0, r1, &Math())
  841 	XuiSendMessage ( grid, #SetGridName, 0, 0, 0, 0, 0, @"Math")
  842   XuiRadioButton (@g, #Create, 4, 4, 64, 20, r0, grid)
  843   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SIN, grid)
  844   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SIN")
  845   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  846   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SIN")
  847   XuiRadioButton (@g, #Create, 68, 4, 64, 20, r0, grid)
  848   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ASIN, grid)
  849   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ASIN")
  850   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  851   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ASIN")
  852   XuiLabel       (@g, #Create, 132, 4, 248, 248, r0, grid)
  853   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Graphic")
  854   XuiSendMessage ( g, #SetColor, 7, 0, 0, 124, 0, 0)
  855   XuiLabel       (@g, #Create, 140, 12, 232, 232, r0, grid)
  856   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Graph")
  857   XuiSendMessage ( g, #SetColor, 0, 0, 0, 124, 0, 0)
  858   XuiSendMessage ( g, #SetBorder, $$BorderHiLine1, $$BorderHiLine1, $$BorderRaise1, -1, 0, 0)
  859 	XuiSendMessage ( g, #SetMessageFunc, #RedrawGrid, &MathCode(), 0, 0, 0, 0)
  860   XuiRadioButton (@g, #Create, 4, 24, 64, 20, r0, grid)
  861   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $COS, grid)
  862   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"COS")
  863   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  864   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"COS")
  865   XuiRadioButton (@g, #Create, 68, 24, 64, 20, r0, grid)
  866   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACOS, grid)
  867   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACOS")
  868   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  869   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACOS")
  870   XuiRadioButton (@g, #Create, 4, 44, 64, 20, r0, grid)
  871   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $TAN, grid)
  872   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"TAN")
  873   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  874   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"TAN")
  875   XuiRadioButton (@g, #Create, 68, 44, 64, 20, r0, grid)
  876   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ATAN, grid)
  877   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ATAN")
  878   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  879   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ATAN")
  880   XuiRadioButton (@g, #Create, 4, 64, 64, 20, r0, grid)
  881   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $COT, grid)
  882   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"COT")
  883   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  884   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"COT")
  885   XuiRadioButton (@g, #Create, 68, 64, 64, 20, r0, grid)
  886   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACOT, grid)
  887   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACOT")
  888   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  889   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACOT")
  890   XuiRadioButton (@g, #Create, 4, 84, 64, 20, r0, grid)
  891   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SEC, grid)
  892   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SEC")
  893   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  894   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SEC")
  895   XuiRadioButton (@g, #Create, 68, 84, 64, 20, r0, grid)
  896   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ASEC, grid)
  897   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ASEC")
  898   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  899   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ASEC")
  900   XuiRadioButton (@g, #Create, 4, 104, 64, 20, r0, grid)
  901   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $CSC, grid)
  902   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"CSC")
  903   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  904   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"CSC")
  905   XuiRadioButton (@g, #Create, 68, 104, 64, 20, r0, grid)
  906   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACSC, grid)
  907   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACSC")
  908   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  909   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACSC")
  910   XuiRadioButton (@g, #Create, 4, 132, 64, 20, r0, grid)
  911   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SINH, grid)
  912   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SINH")
  913   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  914   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SINH")
  915   XuiRadioButton (@g, #Create, 68, 132, 64, 20, r0, grid)
  916   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ASINH, grid)
  917   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ASINH")
  918   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  919   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ASINH")
  920   XuiRadioButton (@g, #Create, 4, 152, 64, 20, r0, grid)
  921   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $COSH, grid)
  922   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"COSH")
  923   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  924   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"COSH")
  925   XuiRadioButton (@g, #Create, 68, 152, 64, 20, r0, grid)
  926   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACOSH, grid)
  927   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACOSH")
  928   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  929   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACOSH")
  930   XuiRadioButton (@g, #Create, 4, 172, 64, 20, r0, grid)
  931   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $TANH, grid)
  932   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"TANH")
  933   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  934   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"TANH")
  935   XuiRadioButton (@g, #Create, 68, 172, 64, 20, r0, grid)
  936   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ATANH, grid)
  937   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ATANH")
  938   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  939   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ATANH")
  940   XuiRadioButton (@g, #Create, 4, 192, 64, 20, r0, grid)
  941   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $COTH, grid)
  942   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"COTH")
  943   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  944   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"COTH")
  945   XuiRadioButton (@g, #Create, 68, 192, 64, 20, r0, grid)
  946   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACOTH, grid)
  947   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACOTH")
  948   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  949   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACOTH")
  950   XuiRadioButton (@g, #Create, 4, 212, 64, 20, r0, grid)
  951   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SECH, grid)
  952   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SECH")
  953   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  954   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SECH")
  955   XuiRadioButton (@g, #Create, 68, 212, 64, 20, r0, grid)
  956   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ASECH, grid)
  957   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ASECH")
  958   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  959   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ASECH")
  960   XuiRadioButton (@g, #Create, 4, 232, 64, 20, r0, grid)
  961   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $CSCH, grid)
  962   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"CSCH")
  963   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  964   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"CSCH")
  965   XuiRadioButton (@g, #Create, 68, 232, 64, 20, r0, grid)
  966   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $ACSCH, grid)
  967   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"ACSCH")
  968   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  969   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"ACSCH")
  970   XuiRadioButton (@g, #Create, 4, 260, 64, 20, r0, grid)
  971   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $SQRT, grid)
  972   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"SQRT")
  973   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  974   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"SQRT")
  975   XuiRadioButton (@g, #Create, 68, 260, 64, 20, r0, grid)
  976   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $POWER, grid)
  977   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"POWER")
  978   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  979   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"POWER")
  980   XuiLabel       (@g, #Create, 132, 260, 248, 20, r0, grid)
  981   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Range")
  982   XuiSendMessage ( g, #SetColor, 61, 0, 0, 124, 0, 0)
  983   XuiSendMessage ( g, #SetAlign, $$AlignMiddleLeft, -1, 4, 0, 0, 0)
  984   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Range:")
  985   XuiRadioButton (@g, #Create, 4, 280, 64, 20, r0, grid)
  986   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $LOG, grid)
  987   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"LOG")
  988   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
  989   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"LOG")
  990   XuiRadioButton (@g, #Create, 68, 280, 64, 20, r0, grid)
  991   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $EXP, grid)
  992   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"EXP")
  993   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
  994   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"EXP")
  995   XuiLabel       (@g, #Create, 132, 280, 248, 20, r0, grid)
  996   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Maximum")
  997   XuiSendMessage ( g, #SetColor, 56, 0, 0, 124, 0, 0)
  998   XuiSendMessage ( g, #SetAlign, $$AlignMiddleLeft, -1, 4, 0, 0, 0)
  999   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Maximum:")
 1000   XuiRadioButton (@g, #Create, 4, 300, 64, 20, r0, grid)
 1001   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $LOG10, grid)
 1002   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"LOG10")
 1003   XuiSendMessage ( g, #SetColor, 18, 0, 0, 124, 0, 0)
 1004   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"LOG10")
 1005   XuiRadioButton (@g, #Create, 68, 300, 64, 20, r0, grid)
 1006   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $EXP10, grid)
 1007   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"EXP10")
 1008   XuiSendMessage ( g, #SetColor, 16, 0, 0, 124, 0, 0)
 1009   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"EXP10")
 1010   XuiLabel       (@g, #Create, 132, 300, 248, 20, r0, grid)
 1011   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Minimum")
 1012   XuiSendMessage ( g, #SetColor, 56, 0, 0, 124, 0, 0)
 1013   XuiSendMessage ( g, #SetAlign, $$AlignMiddleLeft, -1, 4, 0, 0, 0)
 1014   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Minimum:")
 1015   XuiRadioButton (@g, #Create, 4, 320, 64, 20, r0, grid)
 1016   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $CLEAR, grid)
 1017   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"CLEAR")
 1018   XuiSendMessage ( g, #SetColor, 15, 0, 0, 124, 0, 0)
 1019   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"CLEAR")
 1020   XuiRadioButton (@g, #Create, 68, 320, 64, 20, r0, grid)
 1021   XuiSendMessage ( g, #SetCallback, grid, &Math(), -1, -1, $QUIT, grid)
 1022   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"QUIT")
 1023   XuiSendMessage ( g, #SetColor, 78, 0, 0, 124, 0, 0)
 1024   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"QUIT")
 1025 	XuiSendMessage ( g, #SetTexture, $$TextureShadow, $$TextureShadow, 0, 0, 0, 0)
 1026   XuiLabel       (@g, #Create, 132, 320, 248, 20, r0, grid)
 1027   XuiSendMessage ( g, #SetGridName, 0, 0, 0, 0, 0, @"Comment")
 1028   XuiSendMessage ( g, #SetColor, 57, 0, 0, 124, 0, 0)
 1029   XuiSendMessage ( g, #SetAlign, $$AlignMiddleLeft, -1, 4, 0, 0, 0)
 1030   XuiSendMessage ( g, #SetTextString, 0, 0, 0, 0, 0, @"Comment:")
 1031   GOSUB Resize
 1032 END SUB
 1033 '
 1034 '
 1035 ' *****  CreateWindow  *****  v0123 = xywh : r0 = windowType : r1$ = display$
 1036 '
 1037 SUB CreateWindow
 1038   IF (v0 =  0) THEN v0 = designX
 1039   IF (v1 =  0) THEN v1 = designY
 1040   IF (v2 <= 0) THEN v2 = designWidth
 1041   IF (v3 <= 0) THEN v3 = designHeight
 1042   XuiWindow (@window, #WindowCreate, v0, v1, v2, v3, r0, @r1$)
 1043   v0 = 0 : v1 = 0 : r0 = window : ATTACH r1$ TO display$
 1044   GOSUB Create
 1045 	r1 = 0 : ATTACH display$ TO r1$
 1046   XuiWindow (window, #WindowRegister, grid, -1, v2, v3, @r0, @"Math")
 1047 END SUB
 1048 '
 1049 '
 1050 ' *****  GetSmallestSize  *****
 1051 '
 1052 SUB GetSmallestSize
 1053 END SUB
 1054 '
 1055 '
 1056 ' *****  Resize  *****
 1057 '
 1058 SUB Resize
 1059 END SUB
 1060 '
 1061 '
 1062 ' *****  Selection  *****
 1063 '
 1064 SUB Selection
 1065 END SUB
 1066 '
 1067 '
 1068 ' *****  Initialize  *****
 1069 '
 1070 SUB Initialize
 1071   XuiGetDefaultMessageFuncArray (@func[])
 1072   XgrMessageNameToNumber (@"LastMessage", @upperMessage)
 1073 '
 1074   func[#Callback]           = &XuiCallback()
 1075   func[#Resize]             = &XuiResizeNot()
 1076 '
 1077   DIM sub[upperMessage]
 1078   sub[#Create]              = SUBADDRESS (Create)
 1079   sub[#CreateWindow]        = SUBADDRESS (CreateWindow)
 1080 '
 1081   IF sub[0] THEN PRINT "First(): Initialize: Error::: Undefined Message"
 1082   IF func[0] THEN PRINT "First(): Initialize: Error::: Undefined Message"
 1083   XuiRegisterGridType (@Math, "Math", &Math(), @func[], @sub[])
 1084 '
 1085   designX = 800
 1086   designY = 23
 1087   designWidth = 384
 1088   designHeight = 344
 1089 '
 1090   gridType = Math
 1091   XuiSetGridTypeValue (gridType, @"x",                designX)
 1092   XuiSetGridTypeValue (gridType, @"y",                designY)
 1093   XuiSetGridTypeValue (gridType, @"width",            designWidth)
 1094   XuiSetGridTypeValue (gridType, @"height",           designHeight)
 1095   XuiSetGridTypeValue (gridType, @"maxWidth",         designWidth)
 1096   XuiSetGridTypeValue (gridType, @"maxHeight",        designHeight)
 1097   XuiSetGridTypeValue (gridType, @"minWidth",         designWidth)
 1098   XuiSetGridTypeValue (gridType, @"minHeight",        designHeight)
 1099   XuiSetGridTypeValue (gridType, @"border",           $$BorderFrame)
 1100   XuiSetGridTypeValue (gridType, @"can",              $$Respond OR $$Callback)
 1101   IFZ message THEN RETURN
 1102 END SUB
 1103 END FUNCTION
 1104 '
 1105 '
 1106 ' #########################
 1107 ' #####  MathCode ()  #####
 1108 ' #########################
 1109 '
 1110 FUNCTION  MathCode (grid, message, v0, v1, v2, v3, r0, r1)
 1111 	STATIC	graph
 1112 	STATIC	func
 1113 '
 1114   $Math     =  0  ' kid  0 grid type = Math
 1115   $SIN      =  1  ' kid  1 grid type = XuiRadioButton
 1116   $ASIN     =  2  ' kid  2 grid type = XuiRadioButton
 1117   $Graphic  =  3  ' kid  3 grid type = XuiLabel
 1118   $Graph    =  4  ' kid  4 grid type = XuiLabel
 1119   $COS      =  5  ' kid  5 grid type = XuiRadioButton
 1120   $ACOS     =  6  ' kid  6 grid type = XuiRadioButton
 1121   $TAN      =  7  ' kid  7 grid type = XuiRadioButton
 1122   $ATAN     =  8  ' kid  8 grid type = XuiRadioButton
 1123   $COT      =  9  ' kid  9 grid type = XuiRadioButton
 1124   $ACOT     = 10  ' kid 10 grid type = XuiRadioButton
 1125   $SEC      = 11  ' kid 11 grid type = XuiRadioButton
 1126   $ASEC     = 12  ' kid 12 grid type = XuiRadioButton
 1127   $CSC      = 13  ' kid 13 grid type = XuiRadioButton
 1128   $ACSC     = 14  ' kid 14 grid type = XuiRadioButton
 1129   $SINH     = 15  ' kid 15 grid type = XuiRadioButton
 1130   $ASINH    = 16  ' kid 16 grid type = XuiRadioButton
 1131   $COSH     = 17  ' kid 17 grid type = XuiRadioButton
 1132   $ACOSH    = 18  ' kid 18 grid type = XuiRadioButton
 1133   $TANH     = 19  ' kid 19 grid type = XuiRadioButton
 1134   $ATANH    = 20  ' kid 20 grid type = XuiRadioButton
 1135   $COTH     = 21  ' kid 21 grid type = XuiRadioButton
 1136   $ACOTH    = 22  ' kid 22 grid type = XuiRadioButton
 1137   $SECH     = 23  ' kid 23 grid type = XuiRadioButton
 1138   $ASECH    = 24  ' kid 24 grid type = XuiRadioButton
 1139   $CSCH     = 25  ' kid 25 grid type = XuiRadioButton
 1140   $ACSCH    = 26  ' kid 26 grid type = XuiRadioButton
 1141   $SQRT     = 27  ' kid 27 grid type = XuiRadioButton
 1142   $POWER    = 28  ' kid 28 grid type = XuiRadioButton
 1143   $Range    = 29  ' kid 29 grid type = XuiLabel
 1144   $LOG      = 30  ' kid 30 grid type = XuiRadioButton
 1145   $EXP      = 31  ' kid 31 grid type = XuiRadioButton
 1146   $Maximum  = 32  ' kid 32 grid type = XuiLabel
 1147   $LOG10    = 33  ' kid 33 grid type = XuiRadioButton
 1148   $EXP10    = 34  ' kid 34 grid type = XuiRadioButton
 1149   $Minimum  = 35  ' kid 35 grid type = XuiLabel
 1150   $CLEAR    = 36  ' kid 36 grid type = XuiRadioButton
 1151   $QUIT     = 37  ' kid 37 grid type = XuiRadioButton
 1152   $Comment  = 38  ' kid 38 grid type = XuiLabel
 1153 '
 1154 	IFZ graph THEN GOSUB Initialize
 1155 '	XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
 1156 	IF (message = #Callback) THEN message = r1
 1157 '
 1158 	SELECT CASE message
 1159 '   CASE #Help				:	GOSUB Help        ' callback when help requested
 1160 		CASE #CloseWindow	:	GOSUB CloseWindow	' window closed by system menu
 1161 		CASE #RedrawGrid	: GOSUB RedrawGrid	' graph cleared - redraw trig
 1162     CASE #Selection		:	GOSUB Selection   ' common callback message
 1163 '   CASE #TextEvent		:	GOSUB TextEvent   ' from TextArea and TextLine
 1164 	END SELECT
 1165 	RETURN
 1166 '
 1167 '
 1168 ' *****  CloseWindow  *****
 1169 '
 1170 SUB CloseWindow
 1171 	PRINT "MathCode() : windowType handles CloseWindow from system menu"
 1172 END SUB
 1173 '
 1174 '
 1175 ' *****  RedrawGrid  *****
 1176 '
 1177 SUB RedrawGrid
 1178 	XuiRedrawGrid (grid, #RedrawGrid, 0, 0, 0, 0, 0, 0)
 1179 	r0 = func										' same curve as before
 1180 	v0 = $$TRUE									' simulate select button
 1181 	GOSUB Selection							'	redraw the curve
 1182 END SUB
 1183 '
 1184 '
 1185 ' *****  Selection  *****
 1186 '
 1187 SUB Selection
 1188 	IFZ v0 THEN EXIT SUB
 1189 	func = r0
 1190 	SELECT CASE r0
 1191 		CASE $SIN			:	GOSUB PlotSIN
 1192 		CASE $COS			:	GOSUB PlotCOS
 1193 		CASE $TAN			:	GOSUB PlotTAN
 1194 		CASE $COT			:	GOSUB PlotCOT
 1195 		CASE $SEC			:	GOSUB PlotSEC
 1196 		CASE $CSC			:	GOSUB PlotCSC
 1197 '
 1198 		CASE $ASIN		:	GOSUB PlotASIN
 1199 		CASE $ACOS		:	GOSUB PlotACOS
 1200 		CASE $ATAN		:	GOSUB PlotATAN
 1201 		CASE $ACOT		:	GOSUB PlotACOT
 1202 		CASE $ASEC		:	GOSUB PlotASEC
 1203 		CASE $ACSC		:	GOSUB PlotACSC
 1204 '
 1205 		CASE $SINH		:	GOSUB PlotSINH
 1206 		CASE $COSH		:	GOSUB PlotCOSH
 1207 		CASE $TANH		:	GOSUB PlotTANH
 1208 		CASE $COTH		:	GOSUB PlotCOTH
 1209 		CASE $SECH		:	GOSUB PlotSECH
 1210 		CASE $CSCH		:	GOSUB PlotCSCH
 1211 '
 1212 		CASE $ASINH		:	GOSUB PlotASINH
 1213 		CASE $ACOSH		:	GOSUB PlotACOSH
 1214 		CASE $ATANH		:	GOSUB PlotATANH
 1215 		CASE $ACOTH		:	GOSUB PlotACOTH
 1216 		CASE $ASECH		:	GOSUB PlotASECH
 1217 		CASE $ACSCH		:	GOSUB PlotACSCH
 1218 '
 1219 		CASE $SQRT		:	GOSUB PlotSQRT
 1220 		CASE $POWER		:	GOSUB PlotPOWER
 1221 		CASE $LOG			:	GOSUB PlotLOG
 1222 		CASE $EXP			:	GOSUB PlotEXP
 1223 		CASE $LOG10		:	GOSUB PlotLOG10
 1224 		CASE $EXP10		:	GOSUB PlotEXP10
 1225 '
 1226 		CASE $CLEAR		:	XgrClearGrid (graph, -1) : GOSUB DrawAxes
 1227 		CASE $QUIT		:	QUIT(0)
 1228 		CASE ELSE			:	func = 0
 1229 	END SELECT
 1230 END SUB
 1231 '
 1232 '
 1233 ' *****  DrawAxes  *****
 1234 '
 1235 SUB DrawAxes
 1236 	XgrClearGrid (graph, -1)
 1237 	XgrSetGridBoxScaled (graph, -1#, -1#, +1#, +1#)
 1238 	XgrDrawLineScaled (graph, $$Green, -1#, 0#, +1#, 0#)
 1239 	XgrDrawLineScaled (graph, $$Green, 0#, +1#, 0#, -1#)
 1240 	XgrDrawBoxScaled (graph, $$BrightGreen, -1#, -1#, +1#, +1#)
 1241 	XuiSendMessage (grid, #SetTextString, 0, 0, 0, 0, $Range,   "Range::: " + range$)
 1242 	XuiSendMessage (grid, #SetTextString, 0, 0, 0, 0, $Minimum, "Minumum: " + minimum$)
 1243 	XuiSendMessage (grid, #SetTextString, 0, 0, 0, 0, $Maximum, "Maximum: " + maximum$)
 1244 	XuiSendMessage (grid, #SetTextString, 0, 0, 0, 0, $Comment, "Comment: " + comment$)
 1245 	XuiSendMessage (grid, #Redraw, 0, 0, 0, 0, $Range, 0)
 1246 	XuiSendMessage (grid, #Redraw, 0, 0, 0, 0, $Minimum, 0)
 1247 	XuiSendMessage (grid, #Redraw, 0, 0, 0, 0, $Maximum, 0)
 1248 	XuiSendMessage (grid, #Redraw, 0, 0, 0, 0, $Comment, 0)
 1249 	range$ = ""
 1250 	minimum$ = ""
 1251 	maximum$ = ""
 1252 	comment$ = ""
 1253 END SUB
 1254 '
 1255 '
 1256 ' *****  PlotSIN  *****
 1257 '
 1258 SUB PlotSIN
 1259 	range$ = "-2PI to +2PI"
 1260 	minimum$ = "-1"
 1261 	maximum$ = "+1"
 1262 	comment$ = "SIN()"
 1263 	GOSUB DrawAxes
 1264 	XgrSetGridBoxScaled (graph, -$$TWOPI, 1#, $$TWOPI, -1#)
 1265 	x# = -$$TWOPI
 1266 	y# = SIN (x#)
 1267 	XgrMoveToScaled (graph, x#, y#)
 1268 	FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
 1269 		y# = SIN(x#)
 1270 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1271 	NEXT x#
 1272 END SUB
 1273 '
 1274 SUB PlotCOS
 1275 	range$ = "-2PI to +2PI"
 1276 	minimum$ = "-1"
 1277 	maximum$ = "+1"
 1278 	comment$ = "COS()"
 1279 	GOSUB DrawAxes
 1280 	XgrSetGridBoxScaled (graph, -$$TWOPI, 1#, $$TWOPI, -1#)
 1281 	x# = -$$TWOPI
 1282 	y# = COS (x#)
 1283 	XgrMoveToScaled (graph, x#, y#)
 1284 	FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
 1285 		y# = COS (x#)
 1286 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1287 	NEXT x#
 1288 END SUB
 1289 '
 1290 SUB PlotTAN
 1291 	range$ = "-2PI to +2PI"
 1292 	minimum$ = "-4"
 1293 	maximum$ = "+4"
 1294 	comment$ = "TAN()"
 1295 	GOSUB DrawAxes
 1296 	XgrSetGridBoxScaled (graph, -$$TWOPI, 4#, $$TWOPI, -4#)
 1297 	x# = -$$TWOPI
 1298 	y# = TAN (x#)
 1299 	XgrMoveToScaled (graph, x#, y#)
 1300 	FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
 1301 		y# = TAN (x#)
 1302 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1303 	NEXT x#
 1304 END SUB
 1305 '
 1306 SUB PlotCOT
 1307 	range$ = "-2PI to +2PI"
 1308 	minimum$ = "-4"
 1309 	maximum$ = "+4"
 1310 	comment$ = "COT()"
 1311 	GOSUB DrawAxes
 1312 	XgrSetGridBoxScaled (graph, -$$TWOPI, 4#, $$TWOPI, -4#)
 1313 	x# = -$$TWOPI
 1314 	y# = COT (x#)
 1315 	XgrMoveToScaled (graph, x#, y#)
 1316 	FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
 1317 		y# = COT (x#)
 1318 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1319 	NEXT x#
 1320 END SUB
 1321 '
 1322 SUB PlotSEC
 1323 	range$ = "-2PI to +2PI"
 1324 	minimum$ = "-4"
 1325 	maximum$ = "+4"
 1326 	comment$ = "SEC()"
 1327 	GOSUB DrawAxes
 1328 	XgrSetGridBoxScaled (graph, -$$TWOPI, 4#, $$TWOPI, -4#)
 1329 	x# = -$$TWOPI
 1330 	y# = SEC (x#)
 1331 	XgrMoveToScaled (graph, x#, y#)
 1332 	FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
 1333 		y# = SEC (x#)
 1334 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1335 	NEXT x#
 1336 END SUB
 1337 '
 1338 SUB PlotCSC
 1339 	range$ = "-2PI to +2PI"
 1340 	minimum$ = "-4"
 1341 	maximum$ = "+4"
 1342 	comment$ = "CSC()"
 1343 	GOSUB DrawAxes
 1344 	XgrSetGridBoxScaled (graph, -$$TWOPI, 4#, $$TWOPI, -4#)
 1345 	x# = -$$TWOPI
 1346 	y# = CSC (x#)
 1347 	XgrMoveToScaled (graph, x#, y#)
 1348 	FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
 1349 		y# = CSC (x#)
 1350 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1351 	NEXT x#
 1352 END SUB
 1353 '
 1354 '
 1355 ' *****  PlotASIN  *****
 1356 '
 1357 SUB PlotASIN
 1358 	range$ = "-1 to +1"
 1359 	minimum$ = "-PI/2"
 1360 	maximum$ = "+PI/2"
 1361 	comment$ = "ASIN()"
 1362 	GOSUB DrawAxes
 1363 	XgrSetGridBoxScaled (graph, -1#, +$$PIDIV2, +1#, -$$PIDIV2)
 1364 	x# = -1#
 1365 	y# = ASIN (x#)
 1366 	XgrMoveToScaled (graph, x#, y#)
 1367 	FOR x# = -1# TO +1# STEP (1#/64#)
 1368 		y# = ASIN(x#)
 1369 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1370 	NEXT x#
 1371 END SUB
 1372 '
 1373 SUB PlotACOS
 1374 	range$ = "-1 to +1"
 1375 	minimum$ = "-PI"
 1376 	maximum$ = "+PI"
 1377 	comment$ = "ACOS()"
 1378 	GOSUB DrawAxes
 1379 	XgrSetGridBoxScaled (graph, -1#, +$$PI, +1#, -$$PI)
 1380 	x# = -1#
 1381 	y# = ACOS (x#)
 1382 	XgrMoveToScaled (graph, x#, y#)
 1383 	FOR x# = -1# TO +1# STEP (1#/64#)
 1384 		y# = ACOS (x#)
 1385 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1386 	NEXT x#
 1387 END SUB
 1388 '
 1389 SUB PlotATAN
 1390 	range$ = "-8 to +8"
 1391 	minimum$ = "-PI/2"
 1392 	maximum$ = "+PI/2"
 1393 	comment$ = "ATAN()"
 1394 	GOSUB DrawAxes
 1395 	XgrSetGridBoxScaled (graph, -8#, +$$PIDIV2, +8#, -$$PIDIV2)
 1396 	x# = -8#
 1397 	y# = ATAN (x#)
 1398 	XgrMoveToScaled (graph, x#, y#)
 1399 	FOR x# = -8# TO +8# STEP (1#/16#)
 1400 		y# = ATAN (x#)
 1401 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1402 	NEXT x#
 1403 END SUB
 1404 '
 1405 SUB PlotACOT
 1406 	range$ = "-4 to +4"
 1407 	minimum$ = "-PI"
 1408 	maximum$ = "+PI"
 1409 	comment$ = "ACOT()"
 1410 	GOSUB DrawAxes
 1411 	XgrSetGridBoxScaled (graph, -4#, +$$PI, 4#, -$$PI)
 1412 	x# = -4#
 1413 	y# = ACOT (x#)
 1414 	XgrMoveToScaled (graph, x#, y#)
 1415 	FOR x# = -4# TO 4# STEP (1#/16#)
 1416 		y# = ACOT (x#)
 1417 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1418 	NEXT x#
 1419 END SUB
 1420 '
 1421 SUB PlotASEC
 1422 	range$ = "-16 to -1 : +1 to +16"
 1423 	minimum$ = "-PI"
 1424 	maximum$ = "+PI"
 1425 	comment$ = "ASEC()"
 1426 	GOSUB DrawAxes
 1427 	XgrSetGridBoxScaled (graph, -16#, +$$PI, +16#, -$$PI)
 1428 	x# = -16#
 1429 	y# = ASEC (x#)
 1430 	XgrMoveToScaled (graph, x#, y#)
 1431 	FOR x# = -16# TO -1# STEP (.5#)
 1432 		y# = ASEC (x#)
 1433 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1434 	NEXT x#
 1435 	x# = +1#
 1436 	y# = ASEC (x#)
 1437 	XgrMoveToScaled (graph, x#, y#)
 1438 	FOR x# = +1# TO +16# STEP (.5#)
 1439 		y# = ASEC (x#)
 1440 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1441 	NEXT x#
 1442 END SUB
 1443 '
 1444 SUB PlotACSC
 1445 	range$ = "-16 to -1 : +1 to +16"
 1446 	minimum$ = "-PI"
 1447 	maximum$ = "+PI"
 1448 	comment$ = "ACSC()"
 1449 	GOSUB DrawAxes
 1450 	XgrSetGridBoxScaled (graph, -16#, +$$PI, +16#, -$$PI)
 1451 	x# = -16#
 1452 	y# = ACSC (x#)
 1453 	XgrMoveToScaled (graph, x#, y#)
 1454 	FOR x# = -16# TO -1# STEP (.5#)
 1455 		y# = ACSC (x#)
 1456 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1457 	NEXT x#
 1458 	x# = +1#
 1459 	y# = ACSC (x#)
 1460 	XgrMoveToScaled (graph, x#, y#)
 1461 	FOR x# = +1# TO +16# STEP (.5#)
 1462 		y# = ACSC (x#)
 1463 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1464 	NEXT x#
 1465 END SUB
 1466 '
 1467 '
 1468 ' *****  PlotSINH  *****
 1469 '
 1470 SUB PlotSINH
 1471 	range$ = "-2 to +2"
 1472 	minimum$ = "-2"
 1473 	maximum$ = "+2"
 1474 	comment$ = "SINH()"
 1475 	GOSUB DrawAxes
 1476 	XgrSetGridBoxScaled (graph, -2#, +2#, +2#, -2#)
 1477 	x# = -2#
 1478 	y# = SINH (x#)
 1479 	XgrMoveToScaled (graph, x#, y#)
 1480 	FOR x# = -2# TO +2# STEP (.0625#)
 1481 		y# = SINH (x#)
 1482 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1483 	NEXT x#
 1484 END SUB
 1485 '
 1486 SUB PlotCOSH
 1487 	range$ = "-4 to +4"
 1488 	minimum$ = "-16"
 1489 	maximum$ = "+16"
 1490 	comment$ = "COSH()"
 1491 	GOSUB DrawAxes
 1492 	XgrSetGridBoxScaled (graph, -4#, +16#, +4#, -16#)
 1493 	x# = -4#
 1494 	y# = COSH (x#)
 1495 	XgrMoveToScaled (graph, x#, y#)
 1496 	FOR x# = -4# TO +4# STEP (.0625#)
 1497 		y# = COSH (x#)
 1498 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1499 	NEXT x#
 1500 END SUB
 1501 '
 1502 SUB PlotTANH
 1503 	range$ = "-PI to +PI"
 1504 	minimum$ = "-1"
 1505 	maximum$ = "+1"
 1506 	comment$ = "TANH()"
 1507 	GOSUB DrawAxes
 1508 	XgrSetGridBoxScaled (graph, -$$PI, +1#, +$$PI, -1#)
 1509 	x# = -$$PI
 1510 	y# = TANH (x#)
 1511 	XgrMoveToScaled (graph, x#, y#)
 1512 	FOR x# = -$$PI TO +$$PI STEP ($$PI/64#)
 1513 		y# = TANH (x#)
 1514 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1515 	NEXT x#
 1516 END SUB
 1517 '
 1518 SUB PlotCOTH
 1519 	range$ = "-2 to +2"
 1520 	minimum$ = "-16"
 1521 	maximum$ = "+16"
 1522 	comment$ = "COTH()"
 1523 	GOSUB DrawAxes
 1524 	XgrSetGridBoxScaled (graph, -2#, +16#, +2#, -16#)
 1525 	x# = -2#
 1526 	y# = COTH (x#)
 1527 	XgrMoveToScaled (graph, x#, y#)
 1528 	FOR x# = -2# TO -.01# STEP (.0625#)
 1529 		y# = COTH (x#)
 1530 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1531 	NEXT x#
 1532 	x# = .01#
 1533 	y# = COTH (x#)
 1534 	XgrMoveToScaled (graph, x#, y#)
 1535 	FOR x# = .01# TO +2# STEP (.0625#)
 1536 		y# = COTH (x#)
 1537 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1538 	NEXT x#
 1539 END SUB
 1540 '
 1541 SUB PlotSECH
 1542 	range$ = "-2PI to +2PI"
 1543 	minimum$ = "-1"
 1544 	maximum$ = "+1"
 1545 	comment$ = "SECH()"
 1546 	GOSUB DrawAxes
 1547 	XgrSetGridBoxScaled (graph, -$$TWOPI, 1#, $$TWOPI, -1#)
 1548 	x# = -$$TWOPI
 1549 	y# = SECH (x#)
 1550 	XgrMoveToScaled (graph, x#, y#)
 1551 	FOR x# = -$$TWOPI TO $$TWOPI STEP ($$PI/64#)
 1552 		y# = SECH (x#)
 1553 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1554 	NEXT x#
 1555 END SUB
 1556 '
 1557 SUB PlotCSCH
 1558 	range$ = "-2 to +2"
 1559 	minimum$ = "-16"
 1560 	maximum$ = "+16"
 1561 	comment$ = "CSCH()"
 1562 	GOSUB DrawAxes
 1563 	XgrSetGridBoxScaled (graph, -2#, +16#, +2#, -16#)
 1564 	x# = -2#
 1565 	y# = CSCH (x#)
 1566 	XgrMoveToScaled (graph, x#, y#)
 1567 	FOR x# = -2# TO -.01# STEP (.0625#)
 1568 		y# = CSCH (x#)
 1569 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1570 	NEXT x#
 1571 	x# = +.01#
 1572 	y# = CSCH (x#)
 1573 	XgrMoveToScaled (graph, x#, y#)
 1574 	FOR x# = .01# TO +2# STEP (.0625#)
 1575 		y# = CSCH (x#)
 1576 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1577 	NEXT x#
 1578 END SUB
 1579 '
 1580 '
 1581 ' *****  PlotASINH  *****
 1582 '
 1583 SUB PlotASINH
 1584 	range$ = "-16 to +16"
 1585 	minimum$ = "-4"
 1586 	maximum$ = "+4"
 1587 	comment$ = "ASINH()"
 1588 	GOSUB DrawAxes
 1589 	XgrSetGridBoxScaled (graph, -16#, +4#, +16#, -4#)
 1590 	x# = -16#
 1591 	y# = ASINH (x#)
 1592 	XgrMoveToScaled (graph, x#, y#)
 1593 	FOR x# = -16# TO +16# STEP (.25#)
 1594 		y# = ASINH (x#)
 1595 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1596 	NEXT x#
 1597 END SUB
 1598 '
 1599 SUB PlotACOSH
 1600 	range$ = "-16 to +16"
 1601 	minimum$ = "-4"
 1602 	maximum$ = "+4"
 1603 	comment$ = "ACOSH()"
 1604 	GOSUB DrawAxes
 1605 	XgrSetGridBoxScaled (graph, -16#, +4#, +16#, -4#)
 1606 	x# = +1#
 1607 	y# = ACOSH (x#)
 1608 	XgrMoveToScaled (graph, x#, y#)
 1609 	FOR x# = +1# TO +16# STEP (.25#)
 1610 		y# = ACOSH (x#)
 1611 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1612 	NEXT x#
 1613 END SUB
 1614 '
 1615 SUB PlotATANH
 1616 	range$ = "-1 to +1"
 1617 	minimum$ = "-2"
 1618 	maximum$ = "+2"
 1619 	comment$ = "ATANH()"
 1620 	GOSUB DrawAxes
 1621 	XgrSetGridBoxScaled (graph, -1#, +2#, +1#, -2#)
 1622 	x# = -.99#
 1623 	y# = ATANH (x#)
 1624 	XgrMoveToScaled (graph, x#, y#)
 1625 	FOR x# = -.99# TO +.99# STEP (1#/64#)
 1626 		y# = ATANH (x#)
 1627 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1628 	NEXT x#
 1629 END SUB
 1630 '
 1631 SUB PlotACOTH
 1632 	range$ = "-4 to +4"
 1633 	minimum$ = "-4"
 1634 	maximum$ = "+4"
 1635 	comment$ = "ACOTH()"
 1636 	GOSUB DrawAxes
 1637 	XgrSetGridBoxScaled (graph, -4#, +4#, +4#, -4#)
 1638 	x# = -4#
 1639 	y# = ACOTH (x#)
 1640 	XgrMoveToScaled (graph, x#, y#)
 1641 	FOR x# = -4# TO -1.01# STEP (.0625#)
 1642 		y# = ACOTH (x#)
 1643 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1644 	NEXT x#
 1645 	x# = +1.01#
 1646 	y# = ACOTH (x#)
 1647 	XgrMoveToScaled (graph, x#, y#)
 1648 	FOR x# = +1.01# TO +4# STEP (.0625#)
 1649 		y# = ACOTH (x#)
 1650 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1651 	NEXT x#
 1652 END SUB
 1653 '
 1654 SUB PlotASECH
 1655 	range$ = "-1 to +1"
 1656 	minimum$ = "-4"
 1657 	maximum$ = "+4"
 1658 	comment$ = "ASECH()"
 1659 	GOSUB DrawAxes
 1660 	XgrSetGridBoxScaled (graph, -1#, +4#, +1#, -4#)
 1661 	x# = .01#
 1662 	y# = ASECH (x#)
 1663 	XgrMoveToScaled (graph, x#, y#)
 1664 	FOR x# = .01# TO 1# STEP (.0625#)
 1665 		y# = ASECH (x#)
 1666 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1667 	NEXT x#
 1668 END SUB
 1669 '
 1670 SUB PlotACSCH
 1671 	range$ = "-4 to +4"
 1672 	minimum$ = "-4"
 1673 	maximum$ = "+4"
 1674 	comment$ = "ACSCH()"
 1675 	GOSUB DrawAxes
 1676 	XgrSetGridBoxScaled (graph, -4#, +4#, +4#, -4#)
 1677 	x# = -4#
 1678 	y# = ACSCH (x#)
 1679 	XgrMoveToScaled (graph, x#, y#)
 1680 	FOR x# = -4# TO -.01# STEP (.0625#)
 1681 		y# = ACSCH (x#)
 1682 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1683 	NEXT x#
 1684 	x# = .01#
 1685 	y# = ACSCH (x#)
 1686 	XgrMoveToScaled (graph, x#, y#)
 1687 	FOR x# = .01# TO +4# STEP (.0625#)
 1688 		y# = ACSCH (x#)
 1689 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1690 	NEXT x#
 1691 END SUB
 1692 '
 1693 '
 1694 ' *****  PlotSQRT  *****
 1695 '
 1696 SUB PlotSQRT
 1697 	range$ = "-1 to +1"
 1698 	minimum$ = "-1"
 1699 	maximum$ = "+1"
 1700 	comment$ = "SQRT()"
 1701 	GOSUB DrawAxes
 1702 	XgrSetGridBoxScaled (graph, -1#, +1#, +1#, -1#)
 1703 	x# = 0#
 1704 	y# = SQRT (x#)
 1705 	XgrMoveToScaled (graph, x#, y#)
 1706 	FOR x# = 0# TO +1# STEP (1#/64#)
 1707 		y# = SQRT (x#)
 1708 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1709 	NEXT x#
 1710 END SUB
 1711 '
 1712 SUB PlotPOWER
 1713 	range$ = "-2 to +2"
 1714 	minimum$ = "-4"
 1715 	maximum$ = "+4"
 1716 	comment$ = "x ** x  (x to the x)"
 1717 	GOSUB DrawAxes
 1718 	XgrSetGridBoxScaled (graph, -2#, +4#, +2#, -4#)
 1719 	x# = .01#
 1720 	y# = POWER (x#, x#)
 1721 	XgrMoveToScaled (graph, x#, y#)
 1722 	FOR x# = .01# TO +2# STEP (1#/64#)
 1723 		y# = POWER (x#, x#)
 1724 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1725 	NEXT x#
 1726 END SUB
 1727 '
 1728 SUB PlotLOG
 1729 	range$ = "-4 to +4"
 1730 	minimum$ = "-4"
 1731 	maximum$ = "+4"
 1732 	comment$ = "LOG()"
 1733 	GOSUB DrawAxes
 1734 	XgrSetGridBoxScaled (graph, -4#, +4#, +4#, -4#)
 1735 	x# = .01#
 1736 	y# = LOG (x#)
 1737 	XgrMoveToScaled (graph, x#, y#)
 1738 	FOR x# = .01# TO +4# STEP (1#/64#)
 1739 		y# = LOG (x#)
 1740 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1741 	NEXT x#
 1742 END SUB
 1743 '
 1744 SUB PlotEXP
 1745 	range$ = "-2 to +2"
 1746 	minimum$ = "-8"
 1747 	maximum$ = "+8"
 1748 	comment$ = "EXP()"
 1749 	GOSUB DrawAxes
 1750 	XgrSetGridBoxScaled (graph, -2#, +8#, +2#, -8#)
 1751 	x# = -2#
 1752 	y# = EXP (x#)
 1753 	XgrMoveToScaled (graph, x#, y#)
 1754 	FOR x# = -2# TO +2# STEP (1#/64#)
 1755 		y# = EXP (x#)
 1756 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1757 	NEXT x#
 1758 END SUB
 1759 '
 1760 SUB PlotLOG10
 1761 	range$ = "-4 to +4"
 1762 	minimum$ = "-4"
 1763 	maximum$ = "+4"
 1764 	comment$ = "LOG10()"
 1765 	GOSUB DrawAxes
 1766 	XgrSetGridBoxScaled (graph, -4#, +4#, +4#, -4#)
 1767 	x# = .01#
 1768 	y# = LOG10 (x#)
 1769 	XgrMoveToScaled (graph, x#, y#)
 1770 	FOR x# = .01# TO +4# STEP (1#/64#)
 1771 		y# = LOG10 (x#)
 1772 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1773 	NEXT x#
 1774 END SUB
 1775 '
 1776 SUB PlotEXP10
 1777 	range$ = "-1 to +1"
 1778 	minimum$ = "-4"
 1779 	maximum$ = "+4"
 1780 	comment$ = "EXP10()"
 1781 	GOSUB DrawAxes
 1782 	XgrSetGridBoxScaled (graph, -1#, +4#, +1#, -4#)
 1783 	x# = -1#
 1784 	y# = EXP10 (x#)
 1785 	XgrMoveToScaled (graph, x#, y#)
 1786 	FOR x# = -1# TO +1# STEP (1#/64#)
 1787 		y# = EXP10 (x#)
 1788 		XgrDrawLineToScaled (graph, $$Yellow, x#, y#)
 1789 	NEXT x#
 1790 END SUB
 1791 '
 1792 '
 1793 ' *****  Initialize  *****
 1794 '
 1795 SUB Initialize
 1796 	XuiSendMessage (grid, #GetGridNumber, @graph, 0, 0, 0, $Graph, 0)
 1797 	XgrSetGridClip (graph, graph)
 1798 END SUB
 1799 END FUNCTION
 1800 '
 1801 '
 1802 ' ########################
 1803 ' #####  Control ()  #####
 1804 ' ########################
 1805 '
 1806 FUNCTION  Control (grid, message, v0, v1, v2, v3, r0, (r1, r1$, r1[], r1$[]))
 1807   STATIC  designX,  designY,  designWidth,  designHeight
 1808   STATIC  SUBADDR  sub[]
 1809   STATIC  upperMessage
 1810   STATIC  Control
 1811 	SHARED	Circle
 1812 	SHARED	Math
 1813 '
 1814   $Control     =  0  ' kid  0 grid type = Control
 1815   $ShowCircle  =  1  ' kid  1 grid type = XuiPushButton
 1816   $ShowMath    =  2  ' kid  2 grid type = XuiPushButton
 1817   $UpperKid    =  2  ' kid maximum
 1818 '
 1819 '
 1820   IFZ sub[] THEN GOSUB Initialize
 1821 ' XuiReportMessage (grid, message, v0, v1, v2, v3, r0, r1)
 1822   IF XuiProcessMessage (grid, message, @v0, @v1, @v2, @v3, @r0, @r1, Control) THEN RETURN
 1823   IF (message <= upperMessage) THEN GOSUB @sub[message]
 1824   RETURN
 1825 '
 1826 '
 1827 ' *****  Callback  *****  message = Callback : r1 = original message
 1828 '
 1829 SUB Callback
 1830   message = r1
 1831   IF (message <= upperMessage) THEN GOSUB @sub[message]
 1832 END SUB
 1833 '
 1834 '
 1835 ' *****  Create  *****  v0123 = xywh : r0 = window : r1 = parent
 1836 '
 1837 SUB Create
 1838   IF (v0 <= 0) THEN v0 = 0
 1839   IF (v1 <= 0) THEN v1 = 0
 1840   IF (v2 <= 0) THEN v2 = designWidth
 1841   IF (v3 <= 0) THEN v3 = designHeight
 1842   XuiCreateGrid (@grid, Control, @v0, @v1, @v2, @v3, r0, r1, &Control())
 1843   XuiSendMessage (grid, #SetGridName, 0, 0, 0, 0, 0, @"Control")
 1844   XuiPushButton (@g, #Create, 4, 4, 316, 112, r0, grid)
 1845   XuiSendMessage (g, #SetCallback, grid, &Control(), -1, -1, $ShowCircle, grid)
 1846   XuiSendMessage (g, #SetGridName, 0, 0, 0, 0, 0, @"ShowCircle")
 1847   XuiSendMessage (g, #SetColor, 7, $$Black, $$Black, $$White, 0, 0)
 1848   XuiSendMessage (g, #SetColorExtra, $$Cyan, 120, $$Black, 120, 0, 0)
 1849   XuiSendMessage (g, #SetTexture, $$TextureShadow, 0, 0, 0, 0, 0)
 1850   XuiSendMessage (g, #SetFont, 640, 400, 400, 0, 0, @"Roman")
 1851   XuiSendMessage (g, #SetTextString, 0, 0, 0, 0, 0, @"Show Circle")
 1852   XuiPushButton (@g, #Create, 4, 116, 316, 112, r0, grid)
 1853   XuiSendMessage (g, #SetCallback, grid, &Control(), -1, -1, $ShowMath, grid)
 1854   XuiSendMessage (g, #SetGridName, 0, 0, 0, 0, 0, @"ShowMath")
 1855   XuiSendMessage (g, #SetColor, $$DarkCyan, $$Black, $$Black, $$White, 0, 0)
 1856   XuiSendMessage (g, #SetColorExtra, $$Cyan, 120, $$Black, $$LightGreen, 0, 0)
 1857   XuiSendMessage (g, #SetTexture, $$TextureShadow, 0, 0, 0, 0, 0)
 1858   XuiSendMessage (g, #SetFont, 640, 400, 400, 0, 0, @"Serif")
 1859   XuiSendMessage (g, #SetTextString, 0, 0, 0, 0, 0, @"Show Math")
 1860   GOSUB Resize
 1861 END SUB
 1862 '
 1863 '
 1864 ' *****  CreateWindow  *****  v0123 = xywh : r0 = windowType : r1$ = display$
 1865 '
 1866 SUB CreateWindow
 1867   IF (v0  = 0) THEN v0 = designX
 1868   IF (v1  = 0) THEN v1 = designY
 1869   IF (v2 <= 0) THEN v2 = designWidth
 1870   IF (v3 <= 0) THEN v3 = designHeight
 1871   XuiWindow (@window, #WindowCreate, v0, v1, v2, v3, r0, @r1$)
 1872   v0 = 0 : v1 = 0 : r0 = window : ATTACH r1$ TO display$
 1873   GOSUB Create
 1874 	r1 = 0 : ATTACH display$ TO r1$
 1875   XuiWindow (window, #WindowRegister, grid, -1, v2, v3, @r0, @"Control")
 1876 END SUB
 1877 '
 1878 '
 1879 ' *****  GetSmallestSize  *****  See "Anatomy of Grid Functions"
 1880 '
 1881 SUB GetSmallestSize
 1882 END SUB
 1883 '
 1884 '
 1885 ' *****  Resize  *****  See "Anatomy of Grid Functions"
 1886 '
 1887 SUB Resize
 1888 END SUB
 1889 '
 1890 '
 1891 ' *****  Selection  *****  See "Anatomy of Grid Functions"
 1892 '
 1893 SUB Selection
 1894   SELECT CASE r0
 1895     CASE $Control     :
 1896     CASE $ShowCircle  :	XuiSendMessage (Circle, #ShowWindow, 0, 0, 0, 0, 0, 0)
 1897     CASE $ShowMath    : XuiSendMessage (Math, #ShowWindow, 0, 0, 0, 0, 0, 0)
 1898   END SELECT
 1899 END SUB
 1900 '
 1901 '
 1902 ' *****  Initialize  *****  ' see "Anatomy of Grid Functions"
 1903 '
 1904 SUB Initialize
 1905   XuiGetDefaultMessageFuncArray (@func[])
 1906   XgrMessageNameToNumber (@"LastMessage", @upperMessage)
 1907 '
 1908   func[#Callback]           = &XuiCallback ()               ' disable to handle Callback messages internally
 1909 ' func[#GetSmallestSize]    = 0                             ' enable to add internal GetSmallestSize routine
 1910 ' func[#Resize]             = 0                             ' enable to add internal Resize routine
 1911 '
 1912   DIM sub[upperMessage]
 1913 ' sub[#Callback]            = SUBADDRESS (Callback)         ' enable to handle Callback messages internally
 1914   sub[#Create]              = SUBADDRESS (Create)           ' must be internal routine
 1915   sub[#CreateWindow]        = SUBADDRESS (CreateWindow)     ' must be internal routine
 1916 ' sub[#GetSmallestSize]     = SUBADDRESS (GetSmallestSize)  ' enable to add internal GetSmallestSize routine
 1917 ' sub[#Resize]              = SUBADDRESS (Resize)           ' enable to add internal Resize routine
 1918   sub[#Selection]           = SUBADDRESS (Selection)        ' routes Selection callbacks to subroutine
 1919 '
 1920   IF sub[0] THEN PRINT "Control(): Initialize: Error::: (Undefined Message)"
 1921   IF func[0] THEN PRINT "Control(): Initialize: Error::: (Undefined Message)"
 1922   XuiRegisterGridType (@Control, "Control", &Control(), @func[], @sub[])
 1923 '
 1924 ' Don't remove the following 4 lines, or WindowFromFunction/WindowToFunction will not work
 1925 '
 1926   designX = 2000
 1927   designY = 2000
 1928   designWidth = 324
 1929   designHeight = 232
 1930 '
 1931   gridType = Control
 1932   XuiSetGridTypeValue (gridType, @"x",                designX)
 1933   XuiSetGridTypeValue (gridType, @"y",                designY)
 1934   XuiSetGridTypeValue (gridType, @"width",            designWidth)
 1935   XuiSetGridTypeValue (gridType, @"height",           designHeight)
 1936   XuiSetGridTypeValue (gridType, @"maxWidth",         designWidth)
 1937   XuiSetGridTypeValue (gridType, @"maxHeight",        designHeight)
 1938   XuiSetGridTypeValue (gridType, @"minWidth",         designWidth)
 1939   XuiSetGridTypeValue (gridType, @"minHeight",        designHeight)
 1940   XuiSetGridTypeValue (gridType, @"border",           $$BorderFrame)
 1941   XuiSetGridTypeValue (gridType, @"can",              $$Focus OR $$Respond OR $$Callback)
 1942   XuiSetGridTypeValue (gridType, @"focusKid",         $ShowCircle)
 1943   IFZ message THEN RETURN
 1944 END SUB
 1945 END FUNCTION
 1946 '
 1947 '
 1948 ' ############################
 1949 ' #####  ControlCode ()  #####
 1950 ' ############################
 1951 '
 1952 FUNCTION  ControlCode (grid, message, v0, v1, v2, v3, kid, r1)
 1953 	SHARED	Circle
 1954 	SHARED	Math
 1955 	STATIC	circle
 1956 	STATIC	math
 1957 '
 1958   $Control     =  0  ' kid  0 grid type = Control
 1959   $ShowCircle  =  1  ' kid  1 grid type = XuiPushButton
 1960   $ShowMath    =  2  ' kid  2 grid type = XuiPushButton
 1961   $UpperKid    =  2  ' kid maximum
 1962 '
 1963 '	XuiReportMessage (grid, message, v0, v1, v2, v3, kid, r1)
 1964   IF (message = #Callback) THEN message = r1
 1965 '
 1966   SELECT CASE message
 1967 		CASE #CloseWindow	:	GOSUB CloseWindow	' close from system menu
 1968     CASE #Selection		: GOSUB Selection   ' common callback message
 1969 '   CASE #TextEvent		: GOSUB TextEvent   ' KeyDown in TextArea or TextLine
 1970   END SELECT
 1971   RETURN
 1972 '
 1973 '
 1974 ' *****  CloseWindow  *****
 1975 '
 1976 SUB CloseWindow
 1977 	PRINT "ControlCode() : ignore CloseWindow from system menu"
 1978 END SUB
 1979 '
 1980 '
 1981 ' *****  Selection  *****
 1982 '
 1983 SUB Selection
 1984   SELECT CASE kid
 1985     CASE $Control     :
 1986     CASE $ShowCircle  : grid = Circle
 1987 												XgrGetGridWindow (grid, @window)
 1988 												XgrGetWindowState (window, @state)
 1989 												SELECT CASE state
 1990 													CASE $$WindowHidden			: XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
 1991 													CASE $$WindowDisplayed	: XuiSendMessage (grid, #HideWindow, 0, 0, 0, 0, 0, 0)
 1992 													CASE $$WindowMaximized	: XuiSendMessage (grid, #HideWindow, 0, 0, 0, 0, 0, 0)
 1993 													CASE $$WindowMinimized	: XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
 1994 													CASE ELSE								: XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
 1995 												END SELECT
 1996     CASE $ShowMath    : grid = Math
 1997 												XgrGetGridWindow (grid, @window)
 1998 												XgrGetWindowState (window, @state)
 1999 												SELECT CASE state
 2000 													CASE $$WindowHidden			: XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
 2001 													CASE $$WindowDisplayed	: XuiSendMessage (grid, #HideWindow, 0, 0, 0, 0, 0, 0)
 2002 													CASE $$WindowMaximized	: XuiSendMessage (grid, #HideWindow, 0, 0, 0, 0, 0, 0)
 2003 													CASE $$WindowMinimized	: XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
 2004 													CASE ELSE								: XuiSendMessage (grid, #ShowWindow, 0, 0, 0, 0, 0, 0)
 2005 												END SELECT
 2006   END SELECT
 2007 END SUB
 2008 END FUNCTION
 2009 END PROGRAM