Follow us on Twitter!
Society leans ever heavily on computers, if you have the power to take out computers you can take out society. - cubeman372
Friday, April 18, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 30
Guests Online: 24
Members Online: 6

Registered Members: 82829
Newest Member: mmoclauq
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

Deleting and Storing Text | STRINGBUFFER


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 29-10-08 00:33
hey all,

Basically what I want to do is make a "cut" function. I already made the code here...

Code

   StringBuffer saveStringBuff;
   int saveStartPosition;
   int saveEndPosition;
   boolean undoable;
   


public Cut(StringBuffer strbuff, int start, int end)
   {
      saveStringBuff = strbuff;
      saveStartPosition = start;
      saveEndPosition = end;
      undoable = false;
      
      //clip.getCopyOfString();
      //StringBuffer result = new StringBuffer(null);
   }

   @Override
   public void execute() {
      saveStringBuff.delete(saveStartPosition, saveEndPosition);
      ClipBoard clip = ClipBoard.getInstance();
      clip.loadString(saveStringBuff.toString());
      undoable = true;
   }




When I call this cut method, it takes in a buffer like "HelloWorld", and will delete from lets say 0 to 5. This will leave left over "World" ... Now, what I am trying to do is store the "Hello" into a separate place for use later.

What I am struggling with is storing the "Hello", I can obviously very easily store "World", but I very much need to store "Hello" instead.

Any help is MUCH appreciated, I can't figure this out. Thank you!


Author

RE: Deleting and Storing Text | STRINGBUFFER


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 29-10-08 00:46
I've just begun learning to program so I can't give you any code, but I'm pretty sure you can save the words that are to be deleted as a string just before they are deleted. Here is a representation in pseudo code seeing as how I don't know the actual commands.

Code

string1="Hello"
remove "Hello"





This would them allow you to reuse the string later, kinda like Microsoft Clipboard. If I am wrong, I apologize, but tI believe myself to be theoretically correct.

EDIT:
After reviewing the code, I came up with a new, possibly correct, pseudo code.
Code

}

@Override
public void execute() {
string1 = saveStringBuff(saveStartPosition, saveEndPosition);
saveStringBuff.delete(saveStartPosition, saveEndPosition);
ClipBoard clip = ClipBoard.getInstance();
clip.loadString(saveStringBuff.toString());
undoable = true;
}






Edited by on 29-10-08 00:50
Author

RE: Deleting and Storing Text | STRINGBUFFER


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 29-10-08 01:51
Thanks for the help! Unfortunately you cannot use the buffer the way you indicated (as far as I know).

I did some research on the buffer class and realized that there is actually a substring function that can be used to snag a copy of the text from the indicated start to end positions.

Thanks again all for any help you gave! I appreciate it Smile