|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
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] |
|
#2
|
||||||
|
||||||
|
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 + "\r\n"); The +2 is there so that it includes the the \r\n 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] |
|
#3
|
||||||
|
||||||
|
Oops! Forgot to upload the quick-and-dirty sample app I put together in the last 5min. Here it is (source and exe provided):
|
|
#4
|
|||||
|
|||||
|
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] Last edited by Raven_Writer : 12-08-2003 at 12:34. |
|
#5
|
||||||
|
||||||
|
Quote:
Code:
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); Quote:
|
|
#6
|
|||||
|
|||||
|
Quote:
That would also get the send line, right? Ok, thanks for clearing up the credit thing. |
|
#7
|
|||||
|
|||||
|
Here's my project so far if anyone wants it.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PBASIC ARCTAN function | Greg Ross | Programming | 14 | 11-05-2003 12:28 |
| Obscure PBASIC for RoboEmu | rbayer | Programming | 1 | 28-03-2003 23:57 |
| PBasic 2.5 vs. 2.0 | Anthony Kesich | Programming | 6 | 09-02-2003 22:06 |
| RoboEmu 1.09 (supports PBASIC 2.5) | rbayer | Programming | 22 | 21-01-2003 17:22 |
| PBASIC Loop Speed? | archiver | 2001 | 3 | 23-06-2002 23:46 |