PBASIC Editor Question

Does anyone know how the editor inserts a stamp directive at a specified line w/o deleting all the other text?

If so, can you please tell me how?

[Credit will be given]

Depends on what language/API you’re trying to do it in. For example, to insert the text stored in the CString object newText into line 2 of a CEdit object named m_big, the code would be:

int i=m_big.LineLength(0)+2;

m_big.SetSel(i, i);
m_big.ReplaceSel(newText + "
");

The +2 is there so that it includes the the
sequence at the end of every line.

The SetSel function will set the current selection, but since the start and end values are the same, it merely moves the insertion point.

ReplaceSel will either replace the currently selected text or insert the text at the current insertion point if there is no current selection.

[edit]
Please don’t worry about “credit” for this. As long as you learn the stuff and write your own code, you really don’t need to credit people. Think of it like learning out of a book–you don’t credit the author unless you copy specific portions of code directly from the book.
[/edit]

Oops! Forgot to upload the quick-and-dirty sample app I put together in the last 5min. Here it is (source and exe provided):

inserttest.zip (29.8 KB)


inserttest.zip (29.8 KB)

Rob – Thanks.

Got anything for the Win32?

Sorry, forgot to mention this.

If the code works for Win32, cool.

>> EDIT: << : About the credit, and this is sorta off-topic, but if I use the code you use in RoboGUI or RoboEmu, to connect to a COM Port, I’d give you credit then, right?

[Sorry, but what you said about giving credit, and my thought on it is totally different…and reading the GNU GPL doesn’t clear it up all that much either]

*Originally posted by Raven_Writer *
**Rob – Thanks.

Got anything for the Win32?
**

The concepts are identical, it’s just the way you call the functions that are different. Instead, it would be:


int i=SendDlgItemMessage(hDlg, ID_OF_TEXT_BOX, EM_LINELENGTH, 0, 0) + 2;
//the first zero above is the line number to retrieve.  The second one should always stay 0.

SendDlgItemMessage(hDlg, ID_OF_TEXT_BOX, EM_SETSEL, i, i);

SendDlgItemMessage(hDlg, ID_OF_TEXT_BOX, EM_REPLACESEL, TRUE, szNewText);

**
>> EDIT: << : About the credit, and this is sorta off-topic, but if I use the code you use in RoboGUI or RoboEmu, to connect to a COM Port, I’d give you credit then, right?
**

If you use the exact code, then yes. If you just use concepts, then no. For example, if you read my serial port whitepaper and directly copy-paste the code, then you would need to give me credit. On the other hand, if you write all your own code using just the ideas in the paper, then you don’t. If it wasn’t this way, every single program I’ve ever written would have to have probably close to a hundred credits, since it would have to include every book, professor, or internet article I’ve ever read/talked with about everything from C++ to MFC to graphics to programming methodology.

*Originally posted by rbayer *
**The concepts are identical, it’s just the way you call the functions that are different. Instead, it would be:


int i=SendDlgItemMessage(hDlg, ID_OF_TEXT_BOX, EM_LINELENGTH, 0, 0) + 2;
//the first zero above is the line number to retrieve.  The second one should always stay 0.

SendDlgItemMessage(hDlg, ID_OF_TEXT_BOX, EM_SETSEL, i, i);

SendDlgItemMessage(hDlg, ID_OF_TEXT_BOX, EM_REPLACESEL, TRUE, szNewText);



 

If you use the exact code, then yes.  If you just use concepts, then no.  For example, if you read my serial port whitepaper and directly copy-paste the code, then you would need to give me credit.  On the other hand, if you write all your own code using just the ideas in the paper, then you don't.  If it wasn't this way, every single program I've ever written would have to have probably close to a hundred credits, since it would have to include every book, professor, or internet article I've ever read/talked with about everything from C++ to MFC to graphics to programming methodology. **

Ok, for the DlgItem stuff, hDlg would be HWND hDlg (but would you have to use this for the edit box or anything, or is it just like a buffer)?

That would also get the send line, right?

Ok, thanks for clearing up the credit thing.

Here’s my project so far if anyone wants it.