| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		AylinCE Grandmaster Cheater Supreme
  Reputation: 37
  Joined: 16 Feb 2017 Posts: 1530
 
  | 
		
			
				 Posted: Mon Jun 10, 2019 7:45 am    Post subject: How to search the line in Memo? | 
				       | 
			 
			
				
  | 
			 
			
				Below is a sample form.
 
The keywords and codes included in the edit are:
 
How to find in Memo line ?
 
 
For example: When I type "Lines 4" in the Edit search bar,
 
The following string should appear on the Memo screen:
 
 
 	  | Code: | 	 		  Lines 4 
 
========
 
AA
 
BB
 
CC
 
======== | 	  
 
 
 	  | Code: | 	 		  Form = createForm(true)
 
control_setSize(Form, 280, 260)
 
form_centerScreen(Form)
 
 
MEMO1 = createMemo(Form)
 
control_setSize(MEMO1, 270, 215)
 
control_setPosition(MEMO1, 5, 35)
 
MEMO1.WordWrap = false
 
MEMO1.ScrollBars = "ssAutoBoth"
 
MEMO1.Lines.Text="========\nLines 1 \n========\nAA\nBB\nCC\n========\nLines 2\n========\nAA\nBB\nCC\n========\nLines 3 \n========\nAA\nBB\nCC\n========\nLines 4 \n========\nAA\nBB\nCC\n========\nLines 5 \n========\nAA\nBB\nCC\n========"
 
 
EDIT1 = createEdit(Form)
 
EDIT1.Width = 270
 
control_setPosition(EDIT1, 5, 5) | 	  
 
 
Thanks in advance for help
 _________________
  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Corroder Grandmaster Cheater Supreme
  Reputation: 75
  Joined: 10 Apr 2015 Posts: 1668
 
  | 
		 | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		AylinCE Grandmaster Cheater Supreme
  Reputation: 37
  Joined: 16 Feb 2017 Posts: 1530
 
  | 
		
			
				 Posted: Mon Jun 10, 2019 11:26 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				Probably related to "selText" and "SelLength".
 
 
But when I coded them, I can't get any answers.
 
 	  | Code: | 	 		  MEMO1.selText = EDIT1.Text
 
MEMO1.SelLength = 100 | 	  
 _________________
  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Dark Byte Site Admin
  Reputation: 470
  Joined: 09 May 2003 Posts: 25807 Location: The netherlands
  | 
		
			
				 Posted: Mon Jun 10, 2019 12:57 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				set the selection using selStart and selLength
 
 
using selText you can get the selected text and change it as well
 _________________
 Do not ask me about online cheats. I don't know any and wont help finding them.
 
 
Like my help? Join me on Patreon so i can keep helping  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		AylinCE Grandmaster Cheater Supreme
  Reputation: 37
  Joined: 16 Feb 2017 Posts: 1530
 
  | 
		
			
				 Posted: Mon Jun 10, 2019 1:30 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Dark Byte wrote: | 	 		  set the selection using selStart and selLength
 
 
using selText you can get the selected text and change it as well | 	  
 
 
 
I tried, but it codes like it's completely ineffective.    
 
Please type in a sample.
 _________________
  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Corroder Grandmaster Cheater Supreme
  Reputation: 75
  Joined: 10 Apr 2015 Posts: 1668
 
  | 
		
			
				 Posted: Mon Jun 10, 2019 10:22 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				I more like using an array table. Example:
 
 
 	  | Code: | 	 		  Form = createForm(true)
 
control_setSize(Form, 280, 260)
 
form_centerScreen(Form)
 
 
MEMO1 = createMemo(Form)
 
control_setSize(MEMO1, 270, 215)
 
control_setPosition(MEMO1, 5, 35)
 
MEMO1.WordWrap = false
 
MEMO1.ScrollBars = "ssAutoBoth"
 
MEMO1.Lines.Text="========\nLines 1 \n========\nAA\nBB\nCC\n========\nLines 2\n========\nAA\nBB\nCC\n========\nLines 3 \n========\nAA\nBB\nCC\n========\nLines 4 \n========\nAA\nBB\nCC\n========\nLines 5 \n========\nAA\nBB\nCC\n========"
 
 
EDIT1 = createEdit(Form)
 
EDIT1.Width = 270
 
control_setPosition(EDIT1, 5, 5)
 
 
dumb = {
 
{idxNo = 'Line 1', idTxt = 'AA BB CC'},
 
{idxNo = 'Line 2', idTxt = 'AA BB CC'},
 
{idxNo = 'Line 3', idTxt = 'AA BB CC'},
 
{idxNo = 'Line 4', idTxt = 'AA BB CC'}
 
}
 
 
function editchange()
 
  finder = tonumber(EDIT1.Text)
 
  index = dumb[finder]
 
  if index == nil then
 
    showMessage('Data not found')
 
  else
 
    MEMO1.clear()
 
    MEMO1.Lines.Add('========')
 
    MEMO1.Lines.Add(index.idxNo)
 
    MEMO1.Lines.Add('========')
 
    local s = index.idTxt
 
     for w in s:gmatch("%S+") do
 
      MEMO1.Lines.Add(w)
 
     end
 
    MEMO1.Lines.Add('========')
 
  end
 
end
 
 
EDIT1.onChange = editchange
 
 | 	  
 
 
To use: Just typing a number on EDIT1 without 'Line', only number 1, 2, 3 and so on
 _________________
 Stealing Code From Stolen Code...
 
And Admit It.. Hmmm....Typically LOL  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		AylinCE Grandmaster Cheater Supreme
  Reputation: 37
  Joined: 16 Feb 2017 Posts: 1530
 
  | 
		
			
				 Posted: Tue Jun 11, 2019 2:30 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				Dude I wrote "Lines1" just for example.
 
This can be a list of more than 300 lines of code.
 
the following code only finds the line.
 
 
 	  | Code: | 	 		  Form = createForm(true)
 
control_setSize(Form, 280, 260)
 
form_centerScreen(Form)
 
 
MEMO1 = createMemo(Form)
 
control_setSize(MEMO1, 270, 215)
 
control_setPosition(MEMO1, 5, 35)
 
MEMO1.WordWrap = false
 
MEMO1.ScrollBars = "ssAutoBoth"
 
MEMO1.WantReturns=(true)
 
 
EDIT1 = createEdit(Form)
 
EDIT1.Width = 180
 
control_setPosition(EDIT1, 5, 5)
 
 
EDIT2 = createButton(Form)
 
control_setPosition(EDIT2, 190, 5)
 
EDIT2.caption = "Search"
 
 
EDIT2.OnClick = function()
 
lines = MEMO1.Lines
 
lines1 = EDIT1.Text
 
MEMO1.Lines.Text=(lines.String[lines1])
 
end
 
 
EDIT1.OnClick = function()
 
MEMO1.Lines.Text="========\nLines 1 \n========\nAA\nBB\nCC\n========\nLines 2\n========\nAA\nBB\nCC\n========\nLines 3 \n========\nAA\nBB\nCC\n========\nLines 4 \n========\nAA\nBB\nCC\n========\nLines 5 \n========\nAA\nBB\nCC\n========"
 
end | 	  
 
 
I don't understand: The following codes are completely ineffective.
 
 
 	  | Code: | 	 		  MEMO1.selStart=EDIT1.Text
 
MEMO1.selLength=200
 
MEMO1.selText | 	  
 
 
I couldn't find an example using these codes.  
 _________________
  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Corroder Grandmaster Cheater Supreme
  Reputation: 75
  Joined: 10 Apr 2015 Posts: 1668
 
  | 
		
			
				 Posted: Tue Jun 11, 2019 4:24 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				 	  | Quote: | 	 		  For example: When I type "Lines 4" in the Edit search bar,
 
The following string should appear on the Memo screen:
 
 
Code:	
 
Lines 4
 
========
 
AA
 
BB
 
CC
 
========	
 
 | 	  
 
 
Why sound like you blame everyone who tries to help you? Did my code give as you wish same like you wrote on the first topic?.
 
 
Now. you said:
 
 
 	  | Quote: | 	 		  Dude I wrote "Lines1" just for example.
 
This can be a list of more than 300 lines of code.  | 	  
 
 
My question: Why you did not say like this on your First post?. I give the code to get text line by line in CEMemo, before:
 
 
To get text line by line from CE Memo, which are:
 
 
 	  | Code: | 	 		  lines = MEMO1.Lines
 
print(lines.String[1])  --- 2, 3, 4 and so on
 
 | 	  
 
 
And I said. try yourself or do some improvisation to manage the code so it according to what you want.
 
 
EDIT:
 
In Lazarus have 'function pos'.  So to find a substring from a string, then use:
 
 
 	  | Code: | 	 		  Memo1.SelStart:= Pos(Edit1.Text, Memo1.Text);
 
Memo1.SelLength := Length(Edit1.Text); | 	  
 
 
Maybe in CE Lua:
 
 
 	  | Code: | 	 		  MEMO1.selStart = string.match(MEMO1.Line,EDIT1.Text)
 
MEMO1.selLength = string.len(EDIT1.Text)
 
 | 	  
 
 
or 
 
 
 	  | Code: | 	 		  function FindText(txt)
 
 txt = EDIT1.Text
 
 local p = 0
 
 local memo = MEMO1.Lines.Text
 
 p = string.find(memo, txt)
 
 local result = p > 0
 
 if result then
 
  MEMO1.selStart = p
 
  MEMO1.selLength = string.len(txt)
 
  MEMO1.selText = txt
 
  MEMO1.setFocus()
 
 end
 
end | 	  
 _________________
 Stealing Code From Stolen Code...
 
And Admit It.. Hmmm....Typically LOL  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		AylinCE Grandmaster Cheater Supreme
  Reputation: 37
  Joined: 16 Feb 2017 Posts: 1530
 
  | 
		
			
				 Posted: Tue Jun 11, 2019 10:34 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				(I mentioned in the title: How to search?   )
 
 
 
I've tried your suggestions now. Thanks. Unfortunately it did not work.  
 
I still don't believe the following code works:  
 
 
 	  | Code: | 	 		  MEMO1.selStart
 
MEMO1.selLength
 
MEMO1.selText | 	  
 
 
patterns of use of these codes may be different.
 
Or it can be written differently.
 _________________
  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Dark Byte Site Admin
  Reputation: 470
  Joined: 09 May 2003 Posts: 25807 Location: The netherlands
  | 
		
			
				 Posted: Tue Jun 11, 2019 11:25 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				try selstart sellength and seltext (all lowercase) but do not use createMemo.  Use a designtime memo (TCEMemo)
 _________________
 Do not ask me about online cheats. I don't know any and wont help finding them.
 
 
Like my help? Join me on Patreon so i can keep helping  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		AylinCE Grandmaster Cheater Supreme
  Reputation: 37
  Joined: 16 Feb 2017 Posts: 1530
 
  | 
		
			
				 Posted: Tue Jun 11, 2019 3:28 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				Thanks DB ..
 
Small capitalization, code made effective.
 
 
 
 	  | Code: | 	 		  function CEButton1Click(sender)
 
UDF1.CEMemo1.selstart = UDF1.CEEdit1.Text
 
UDF1.CEMemo1.sellength = 200
 
UDF1.CEMemo1.Lines.Text = UDF1.CEMemo1.seltext
 
end | 	  
 
 
I hope there's a way to search for text.  
 _________________
  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Dark Byte Site Admin
  Reputation: 470
  Joined: 09 May 2003 Posts: 25807 Location: The netherlands
  | 
		
			
				 Posted: Tue Jun 11, 2019 11:56 pm    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				selstart needs an integer, not text
 
 
 	  | Code: | 	 		  
 
r1,r2=string.find(UDF1.CEMemo1.Text,'something')
 
 
if r1 then
 
  UDF1.CEMemo1.selstart=r1
 
  UDF1.CEMemo1.sellength=r2-r1
 
end
 
 | 	  
 _________________
 Do not ask me about online cheats. I don't know any and wont help finding them.
 
 
Like my help? Join me on Patreon so i can keep helping  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		AylinCE Grandmaster Cheater Supreme
  Reputation: 37
  Joined: 16 Feb 2017 Posts: 1530
 
  | 
		
			
				 Posted: Wed Jun 12, 2019 1:34 am    Post subject:  | 
				       | 
			 
			
				
  | 
			 
			
				With the help of a list, you can search.
 
But constantly updating the list is challenging.
 
Result: Text search function is required.
 
I think @Corroder has launched a study.  
 
I'll wait.
 
Below is a .CT for the example.
 
To jump to a line: Make use of the list.
 
 
example CT:
 
https://www.dosyaupload.com/iXe5
 _________________
  | 
			 
		  | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		Corroder Grandmaster Cheater Supreme
  Reputation: 75
  Joined: 10 Apr 2015 Posts: 1668
 
  | 
		 | 
	
	
		| Back to top | 
		 | 
	
	
		  | 
	
	
		 |