Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to search the line in Memo?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Aylin
Master Cheater
Reputation: 7

Joined: 16 Feb 2017
Posts: 386

PostPosted: Mon Jun 10, 2019 7:45 am    Post subject: How to search the line in Memo? Reply with quote

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

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater
Reputation: 27

Joined: 10 Apr 2015
Posts: 983

PostPosted: Mon Jun 10, 2019 8:25 am    Post subject: Reply with quote

To get text line by line from CE Memo.

Code:
lines = MEMO1.Lines
print(lines.String[1])  --- 2, 3, 4 and so on


So, if you want CEMemo text output as you wish:

Code:
Lines 4
========
AA
BB
CC
========


Then try yourself to manage the output text according to the text structure on all lines in CEMemo.

Note: CEMemo lines count start from 0.
Embarassed Embarassed

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Aylin
Master Cheater
Reputation: 7

Joined: 16 Feb 2017
Posts: 386

PostPosted: Mon Jun 10, 2019 11:26 am    Post subject: Reply with quote

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

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 370

Joined: 09 May 2003
Posts: 21843
Location: The netherlands

PostPosted: Mon Jun 10, 2019 12:57 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Aylin
Master Cheater
Reputation: 7

Joined: 16 Feb 2017
Posts: 386

PostPosted: Mon Jun 10, 2019 1:30 pm    Post subject: Reply with quote

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. Sad Sad
Please type in a sample.

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater
Reputation: 27

Joined: 10 Apr 2015
Posts: 983

PostPosted: Mon Jun 10, 2019 10:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
Aylin
Master Cheater
Reputation: 7

Joined: 16 Feb 2017
Posts: 386

PostPosted: Tue Jun 11, 2019 2:30 am    Post subject: Reply with quote

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. Smile

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater
Reputation: 27

Joined: 10 Apr 2015
Posts: 983

PostPosted: Tue Jun 11, 2019 4:24 am    Post subject: Reply with quote

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
View user's profile Send private message
Aylin
Master Cheater
Reputation: 7

Joined: 16 Feb 2017
Posts: 386

PostPosted: Tue Jun 11, 2019 10:34 am    Post subject: Reply with quote

(I mentioned in the title: How to search? Smile )


I've tried your suggestions now. Thanks. Unfortunately it did not work. Sad
I still don't believe the following code works: Sad

Code:
MEMO1.selStart
MEMO1.selLength
MEMO1.selText


patterns of use of these codes may be different.
Or it can be written differently.

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 370

Joined: 09 May 2003
Posts: 21843
Location: The netherlands

PostPosted: Tue Jun 11, 2019 11:25 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Aylin
Master Cheater
Reputation: 7

Joined: 16 Feb 2017
Posts: 386

PostPosted: Tue Jun 11, 2019 3:28 pm    Post subject: Reply with quote

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. Sad

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 370

Joined: 09 May 2003
Posts: 21843
Location: The netherlands

PostPosted: Tue Jun 11, 2019 11:56 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
Aylin
Master Cheater
Reputation: 7

Joined: 16 Feb 2017
Posts: 386

PostPosted: Wed Jun 12, 2019 1:34 am    Post subject: Reply with quote

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. Smile
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

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater
Reputation: 27

Joined: 10 Apr 2015
Posts: 983

PostPosted: Wed Jun 12, 2019 10:55 pm    Post subject: Reply with quote

Don't wait for me! Very Happy

https://forum.cheatengine.org/viewtopic.php?p=5749682#5749682

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites