Shiny Language Reference
Language Reference > User Interface > Memo Boxes
memoboxreplaceat
bool memoboxreplaceat(int ID, int Pos, int Count, string Text);
Replaces characters in the memobox at the specified position with a new string
The MEMOBOXREPLACEAT statement replaces Count characters beginning at position Pos with the supplied text. You may remove greater or fewer characters from the string than are in the replacement text.
Parameters
ID
The control ID of the control you wish to modify
Pos
The character (byte) position within the memobox to insert the new text at. Remember that the byte position includes single bytes for line feeds (newlines, "\n"). Therefore a caption string of "Line 1\nLine 2" will only display 12 characters on screen, but consists of 13 bytes. Therefore to insert text at the start of "Line 2", the position parameter should be integer 7.
Count
The number of characters to replace.
Text
The string to insert
Return Value
TRUE if the replacement succeeded, otherwise FALSE. Replacement will only fail if an invalid position has been specified.
Example Code
// Create the memo box X: 10, Y:10 and sized 150*70
int iMemoBoxID = creatememobox(1, 10, 10, 150, 70);
// Set the memobox text to "Hello World"
setcaption(iMemoBoxID, "Hello World");
// Insert "big wide" between "Hello" and "World"
bool bRes = memoboxinsertat(iMemoBoxID, 5, " big wide");
// Replace "Hello" with "Welcome to the"
bool bRes = memoboxreplaceat(iMemoBoxID, 0, 5, "Welcome to the");