Quote: "I appreciate that.. But I like the idea of using an array with a set limit (perhaps lets the user change that to their preference as well) because it just seems a lot simpler to fetch that data from the "history".
A user doesn't need an entire history of their play session, I don't think.. just enough to scroll back a few minutes or something like that."
Well I did it that way because it was easy to do with the DATAFILE commands and it makes it easy to just copy that file when the user wants to save their game. Even if they get back to it a week, month, year or several years they have a record of everything they did to get to that point. Plus I thought it would be cool.
Quote: "I'm not sure I'm gonna find an easy way of scrolling the currently viewable text than a FOR/NEXT loop as it is.. and all it would take to all the backbuffer functionality is to include a command to move indices forwards and backwards with the FOR/NEXT loop."
It would be basically what I posted earlier the buffer shows the last 30 lines to the user till they decide to scroll up. The top line currently being viewed changes to show higher/lower in the file or array in your case.
Quote: "I suppose in this case I prefer simplicity over complexity. But I don't know how I'm going to get my colors implemented at this point.. (See my "Colored Text" thread) At least not the way -I- want to do it.. I can't think of a way to get individually colored words within a string, much less keeping those colors when reading it from an array.."
The methods we all posted in your Colored Text thread work fine with a buffer weather or not you use datafiles or arrays to store the strings because the color codes are embedded within the strings ( the |02| or {white} ). That's why in my buffer example I keep 200 characters to make room for many different text color changes within each line. I just took the coloring text part out and the others I mentioned earlier to make it easier to see just the buffer file code.
Quote: "Getting markers into a string is no problem at all, but I don't understand how all those MUD clients can do their parsing to display individually colored words within the same line, etc.. Much less within a text box that scrolls up and down, and which I would assume involves an array of some sort?"
The methods in that thread change color any time a color marker is seen so they can be placed anywhere in the string as many times as you want a color change. You can color individual words or individual letters. The following is a copy of my code snip in that thread with one line added to show 41 color changes in a single line.
` Make background text color show
set text opaque
` Create the UDT for colors
type Col
Fore as dword
Back as dword
endtype
` Dimensionalize the array
dim Color(19) as Col
` Define all background colors
for t=0 to 19
Color(t).Back=rgb(0,0,150)
next t
` Define the colors
Color(0).Fore=rgb(80,80,80) ` Debug Text Color
Color(1).Fore=rgb(0,0,0) ` Status Line Foreground Color
Color(1).Back=rgb(150,150,150) ` Status Line Background Color
Color(2).Fore=rgb(255,255,255) ` Begining Text Color
Color(3).Fore=rgb(0,255,0) ` Room Name Color
Color(4).Fore=rgb(255,255,255) ` Room Description Color
Color(5).Fore=rgb(45,132,238) ` Item Color
Color(6).Fore=rgb(192,102,203) ` Inventory Color
Color(7).Fore=rgb(255,255,0) ` Get Text Symbol >
Color(8).Fore=rgb(255,0,255) ` Command Color
Color(9).Fore=rgb(0,255,0) ` Get Text Prompt \|/
Color(10).Fore=rgb(150,150,150) ` Normal Text Color
Color(11).Fore=rgb(100,100,0) ` Color of ()'s for producing light
Color(12).Fore=rgb(255,255,0) ` Color of producing light ()'s in item list
Color(13).Fore=rgb(93,47,3) ` Color of ()'s for producing light
Color(14).Fore=rgb(157,77,5) ` Color of open and close in item list
Color(15).Fore=rgb(255,128,64) ` Color of L and D in Loading Data...
Color(16).Fore=rgb(213,69,0) ` Color of oading in Loading Data...
Color(17).Fore=rgb(80,80,80) ` Color of ... in Loading Data...
cls Color(0).Back
ColorText(0,0,"|03|Library")
ColorText(0,15,"|04|It's an amazingly |10|large |04|room with countless shelves full of books in every")
ColorText(0,30,"|04|subject known to Earthlings.")
ColorText(0,45,"|05|On the floor is a Diga-mark.")
ColorText(0,75,"|07|> |08|TAKE ALL")
ColorText(0,90,"|10|Diga-mark: Taken")
ColorText(0,120,"|07|> ")
ColorText(0,150,"|00|T|02|h|03|i|04|s |05|l|06|i|07|n|08|e |09|h|10|a|11|s |12|4|13|1 |14|c|15|o|16|l|17|o|00|r |01|c|02|h|03|a|04|n|05|g|06|e|07|s |08|i|09|n |10|o|11|n|12|e |13|s|14|i|15|n|16|g|17|l|00|e |01|l|02|i|03|n|04|e|05|.")
wait key
end
` Function to Color Text ColorText(x coordinate, y coordinate, Text to color)
function ColorText(x,y,Tex$)
for t=1 to len(Tex$)
` Get the character
a$=mid$(Tex$,t)
` Check for color marker
if a$="|"
` Grab the color (two digits)
Color=val(Mids(Tex$,t+1,t+2))
` Change the color
ink Color(Color).Fore,Color(Color).Back
` Advance t so it skips over the |xx|
inc t,3
else
` Show the character
text x,y,a$
` Move x over for the next character
inc x,text width(a$)
endif
next t
` Reset the color
ink Color(2).Fore,Color(2).Back
endfunction
` True basic mid$ command
function Mids(t$,a,b)
a$=left$(right$(t$,len(t$)-a+1),b)
endfunction a$
Quote: "Hitting one of those discouraging roadblocks...meh"
There aren't any roadblocks if you take our advice.
Quote: "I get the rotation part.. But how does blanking out the last item maintain the ability to scroll back through the History of the text buffer? If I rotate, and 0 becomes 19, and then I delete 19 to insert my newest line of text... I have just destroyed my backbuffer data??"
If you have an array thats dimensionalized at 1999 (like you want) and you add a string at the bottom of the array (at 1999) then use IanMs ROTATE ARRAY command the string at 1999 becomes 1998. Clear and add another string at 1999 and ROTATE ARRAY again the string in 1998 is now 1997, the string at 1999 is now at 1998 and 1999 is free to clear to add another string at the end of the buffer. You won't actually see any "destroying" till the first string you added at 1999 travels all the way up the array to element zero. It may sound confusing but it actually does work exactly how I described.