Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How to approach object management (unique ID's, tracking, searching, manipulating)

Author
Message
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Oct 2010 00:10
Quote: "To update screen, call our magic-shift-all-by-1-index command
and then call an ARRAY INSERT AT BOTTOM."

... or rotate by 1 place and then blank out the last item?

TBH, for what you want, you could probably implement this as a circular buffer.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 12th Oct 2010 00:31 Edited at: 12th Oct 2010 00:34
I have to be honest.. I had what amounts to the same idea.

But I was unable to visualize the mechanics and understand how I would implement this in code...

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??

Or... is the idea here to make a very large array, Point to the "middle" as the start, and only print what is in the middle, and then use rotate to give me "breathing" room? TO avoid displaying old data, I clear the element(s?) "Below" the middle section I am printing?


The code examples in the link are beyond me - I don't know C or C++, let alone how to parse their syntax. I'm sorry.


On the good news front.. I was able to figure out how I should be getting my colors in and the line parsed... I just have to test my working sample with an actual array now...

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Oct 2010 10:34
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.



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.

Neco
18
Years of Service
User Offline
Joined: 13th Jul 2008
Location: Waterloo, Wisconsin USA
Posted: 12th Oct 2010 13:53 Edited at: 12th Oct 2010 13:55
Actually the way you described it makes perfect sense. I was probably trying too hard to understand it.

As for the Color thread...well you see, I'm a really indecisive person, lol.. I think I got it sorted in my head though

Login to post a reply

Server time is: 2026-07-22 19:09:21
Your offset time is: 2026-07-22 19:09:21