<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wikiti.brandonw.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wikiti.brandonw.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Christop</id>
		<title>WikiTI - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wikiti.brandonw.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Christop"/>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=Special:Contributions/Christop"/>
		<updated>2026-04-05T19:24:42Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.23.5</generator>

	<entry>
		<id>https://wikiti.brandonw.net/index.php?title=83Plus:OS:Edit_Buffers</id>
		<title>83Plus:OS:Edit Buffers</title>
		<link rel="alternate" type="text/html" href="https://wikiti.brandonw.net/index.php?title=83Plus:OS:Edit_Buffers"/>
				<updated>2011-07-09T18:18:43Z</updated>
		
		<summary type="html">&lt;p&gt;Christop: spelling fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:83Plus:OS Information|Edit Buffers]]&lt;br /&gt;
== Introduction ==&lt;br /&gt;
The edit buffer is used to easily edit the contents of a variable on the calculator. Without the edit buffer, every time you needed to grow or shrink a variable, you would have to use InsertMem or DelMem, and then update the size bytes. For a variable that is constantly changing size, ie. one that's currently having data inputted into it, this is a waste of time for both the CPU and the programmer. The edit buffer solves this problem.&lt;br /&gt;
&lt;br /&gt;
When a variable is edited, all of available RAM is inserted into it. That way, all the other variables in RAM only have to be moved around twice (once when the edit buffer is opened, and once when it's closed), instead of every time a byte needs to be added or removed from the variable. However, this also means that while an edit buffer is open, the application can't allocate any other memory. This means no creating or resizing other programs, and no pushing to or popping from the floating point stack.&lt;br /&gt;
&lt;br /&gt;
== Opening an Edit Buffer ==&lt;br /&gt;
This example assumes the type of variable you're opening in the edit buffer is a program. To edit a currently empty program, use the [[83Plus:BCALLs:4969|SetEmptyEditPtr]] entry point. If you need to edit a program that already has data in it, use some code like this:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;SetupEditStuff:&lt;br /&gt;
	ld hl,progname&lt;br /&gt;
	rst rMov9ToOP1&lt;br /&gt;
	B_CALL EditProg&lt;br /&gt;
	set editOpen,(iy+editFlags) ;Editor is running&lt;br /&gt;
	ld hl,(iMathPtr1)&lt;br /&gt;
	inc hl&lt;br /&gt;
	inc hl&lt;br /&gt;
	ld (editTop),hl ;Top of edit session&lt;br /&gt;
	push hl&lt;br /&gt;
	ld hl,(iMathPtr2)&lt;br /&gt;
	ld (editCursor),hl&lt;br /&gt;
	push hl&lt;br /&gt;
	ex de,hl&lt;br /&gt;
	ld hl,(iMathPtr3)&lt;br /&gt;
	B_CALL CpHLDE&lt;br /&gt;
	jr nc,SetupEditProgSwapSkip&lt;br /&gt;
	ex de,hl&lt;br /&gt;
SetupEditProgSwapSkip:&lt;br /&gt;
	ld (editBtm),hl&lt;br /&gt;
	ld (editTail),hl&lt;br /&gt;
	pop hl&lt;br /&gt;
	pop de&lt;br /&gt;
	or a&lt;br /&gt;
	sbc hl,de&lt;br /&gt;
	ret z&lt;br /&gt;
	ld c,l&lt;br /&gt;
	ld b,h&lt;br /&gt;
	ld hl,(editCursor)&lt;br /&gt;
	dec hl&lt;br /&gt;
	ld de,(editTail)&lt;br /&gt;
	dec de&lt;br /&gt;
	lddr&lt;br /&gt;
	inc hl&lt;br /&gt;
	ld (editCursor),hl&lt;br /&gt;
	inc de&lt;br /&gt;
	ld (editTail),de&lt;br /&gt;
	ret&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Edit Buffer Variables ==&lt;br /&gt;
The edit buffer uses four memory variables to keep track of data in the edit buffer:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[83Plus:RAM:96F4|editTop]]&lt;br /&gt;
:Holds a pointer to the beginning of the edit buffer. This will be directly after the size bytes for the variable. The value in editTop does not change during the course of the edit session.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:RAM:96F6|editCursor]]&lt;br /&gt;
:Holds a pointer to the equivalent location in the edit buffer for the on-screen cursor. The data between editTop and editCursor is all the data to the left of the cursor. The value in editCursor is variable and depends on how much data is to the left of the cursor.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:RAM:96F8|editTail]]&lt;br /&gt;
:Holds a pointer to the all the data that's after the cursor. This data fills the area between editTail and editBtm. The area between editCursor and editTail is the free space for data to grow into.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:RAM:96FA|editBtm]]&lt;br /&gt;
:Holds a pointer to the end of the edit buffer. The value in editBtm is constant and doesn't change during the edit session.&lt;br /&gt;
&lt;br /&gt;
== Navigating the Edit Buffer ==&lt;br /&gt;
Luckily, you don't have to modify the above variables manually; there are entry points provided to help navigate through the edit buffer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[83Plus:BCALLs:4936|BufClear]]&lt;br /&gt;
:Clears all the data in the edit buffer.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:BCALLs:4912|BufDelete]]&lt;br /&gt;
:Deletes the current token from the edit buffer.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:BCALLs:4909|BufInsert]]&lt;br /&gt;
:Inserts a token into the edit buffer, before the current character.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:BCALLs:4903|BufLeft]]&lt;br /&gt;
:Moves the edit pointers to the left.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:BCALLs:490F|BufReplace]]&lt;br /&gt;
:Replaces the current token in the edit buffer.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:BCALLs:4906|BufRight]]&lt;br /&gt;
:Moves the edit pointers to the right.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:BCALLs:4933|IsAtBtm]]&lt;br /&gt;
:Check if the cursor is at the bottom of the edit buffer.&lt;br /&gt;
&lt;br /&gt;
[[83Plus:BCALLs:4930|IsAtTop]]&lt;br /&gt;
:Check if the cursor is at the top of the edit buffer.&lt;br /&gt;
&lt;br /&gt;
== Closing an Edit Session ==&lt;br /&gt;
To close an edit session, use CloseEditEqu. You will probably want to close the edit session as soon as you are done with it, but in any case, it needs to be closed before the app returns to the OS. If you are using GetKey while the edit buffer is open, this means you will you will need to use Put Away notification to close the edit buffer before returning to the OS.&lt;/div&gt;</summary>
		<author><name>Christop</name></author>	</entry>

	</feed>