View previous topic :: View next topic |
Author |
Message |
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
Posted: Thu Jun 27, 2019 8:59 am Post subject: 2 questions, [Help] for Single Project. |
|
|
I'm trying to complete a project.
I must correct and use one of the following 2 alternatives.
Let me tell you from the start:
I've used the CEF search function for 3 days.
I didn't get a close conclusion.
My question: The line I clicked in CEMemo should write to CEEdit.
But the following code writes all CEMemo lines.
Is there a way to get the text on the line?
Code: | function CEMemo1Click(sender)
index = control_getCaption(UDF1.CEMemo1);
if index then
UDF1.CEEdit1.Text=(index)
end
end |
or I can get another suggestion:
I can get a list from a txt file.
but the whole list comes as a single line into CEComboBax.
How do I get the entire list one after the other?
(Code Creator: @mgr.inz.Player and Thanks)
Code: | function ListLoad(sender)
if path then
local settingsFile = io.open(path.."List.txt", "r")
if (settingsFile ~= nil) then
name = settingsFile:read("*a")
UDF1.CEComboBox1.Items.Add(name)
settingsFile:close()
end
end
end |
Whichever proposal is resolved, I will use it.
Thanks in advance for the help.
_________________
|
|
Back to top |
|
|
FreeER Grandmaster Cheater Supreme Reputation: 53
Joined: 09 Aug 2013 Posts: 1091
|
Posted: Thu Jun 27, 2019 2:48 pm Post subject: |
|
|
This seems to work to get the line the cursor is in for a Memo, there doesn't seem to be an option for that currently... Code: | function getMemoLineWithCursorOrSelection(m)
local start = m.SelStart
local ending = m.Lines.Text:find('\n', start)
if ending then ending = ending - 2 else ending = #m.Lines.Text end
-- adjust start by finding previous new line for start of "selected" line
start = m.Lines.Text:sub(0,start):match('^.*()\n')
if start then start = start+1 else start = 0 end
return m.Lines.Text:sub(start, ending)
end
local s = getMemoLineWithCursorOrSelection(UDF1.CEMemo1)
return ("got '%s' as the line"):format(s) | Of course if you're willing to make them select the line then you can just use UDF1.CEMemo1.SelText
edit: I should note that the function ignores "soft" line wrapping, which is on by default. So if the user writes a long line without pressing enter which then wraps onto the next line visually in the memo, the function will still see everything until an actual newline as one "line".
the latter should be as simple as
for line in settingsFile:read("*a"):gmatch('[^\n]+') do UDF1.CEComboBox1.Items.Add(line) end
_________________
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
Posted: Thu Jun 27, 2019 3:52 pm Post subject: |
|
|
big thanks @FreeER, Your critical codes saved me.
Code: | for line in settingsFile:read("*a"):gmatch('[^\n]+') do UDF1.CEComboBox1.Items.Add(line) end |
Code: | function ListLoad(sender)
UDF1.CEComboBox1.Clear()
if path then
local settingsFile = io.open(path.. "List.txt", "r")
if (settingsFile ~= nil) then
-- name = settingsFile:read("*a")
for line in settingsFile:read("*a"):gmatch('[^\n]+') do
UDF1.CEComboBox1.Items.Add(line)
-- settingsFile:close()
end
settingsFile:close()
end
end
end |
and the CEComboBox1 solution is better than using CEMemo.
Too much space opened and convenient.
Thanks again @FreeER ..
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sat Jun 29, 2019 8:05 am Post subject: |
|
|
or select every time text has selected on CEMemo then CEEdit text will display the selected text. Select texts on CEMemo by hold left mouse button and drag to selecting text.
Code: | UDF1.show()
function CEMemo1MouseUp(sender, button, x, y)
UDF1.CEEdit1.Text = UDF1.CEMemo1.SelText
end |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
Posted: Sat Jun 29, 2019 9:04 am Post subject: |
|
|
Corroder wrote: | or select every time text has selected on CEMemo then CEEdit text will display the selected text. Select texts on CEMemo by hold left mouse button and drag to selecting text.
Code: | UDF1.show()
function CEMemo1MouseUp(sender, button, x, y)
UDF1.CEEdit1.Text = UDF1.CEMemo1.SelText
end |
|
This is a good solution thanks @Corroder
However, during the registration of the list title:
"(space character)" should be replaced with "_".
So: If "Game Code" is written,
Must be Game_Code.
CEMemo1 selects the word, not the line,
So the word should be written united, without spaces.
If the user leaves a space between words,
this space must be replaced by "_".
Is there a solution to this?
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sat Jun 29, 2019 9:22 am Post subject: |
|
|
Code: | UDF1.show()
function CEMemo1MouseUp(sender, button, x, y)
txt = UDF1.CEMemo1.SelText
txt = txt:gsub("%s+", "_") -- change every space with _
-- or
-- txt = txt:gsub("%s+", "") -- delete every space
UDF1.CEEdit1.Text = txt
end |
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat Jun 29, 2019 9:26 am Post subject: |
|
|
Code: | UDF1.CEEdit1.Text = (UDF1.CEMemo1.SelText):gsub(' ','_'); |
Edit:
beat me to it )
_________________
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat Jun 29, 2019 11:37 am Post subject: |
|
|
Couldn't quite understand what are you trying to do?
Exaplain what you're trying to do?
create file and save memo content based on the on the selection in the listbox?
_________________
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
Posted: Sat Jun 29, 2019 11:51 am Post subject: |
|
|
The following code:
opens a new file with the given name and
saves this file to the list.
Question: The name of the new file,
How to check if it is available in the list?
Code: | function CEButton2Click(sender)
txt = UDF1.CEEdit2.Text
txt = txt:gsub("%s+", "_")
if txt==UDF1.CEMemo2.seltext then
showMessage("Name Available in list. Please use another name.")
else
UDF1.CEMemo2.Lines.Add(txt)
ListSave()
CreateFile()
showMessage("Code page successfully added to list!")
end
end |
_________________
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat Jun 29, 2019 1:05 pm Post subject: |
|
|
Code: | function CEButton2Click(sender)
local caption = (UDF1.CEEdit2.Text):gsub(' ','_');
for line in (UDF1.CEMemo2.Lines.Text):gmatch('[^\r\n]+') do
if (line == caption) then
showMessage('Name already exists in the list\npick a different one');
return; -- end the function here
end
end
UDF1.CEMemo2.Lines.Add(caption);
ListSave()
CreateFile()
showMessage("Code page successfully added to list!")
end |
_________________
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
Posted: Sat Jun 29, 2019 1:28 pm Post subject: |
|
|
DaSpamer wrote: | Code: | function CEButton2Click(sender)
local caption = (UDF1.CEEdit2.Text):gsub(' ','_');
for line in (UDF1.CEMemo2.Lines.Text):gmatch('[^\r\n]+') do
if (line == caption) then
showMessage('Name already exists in the list\npick a different one');
return; -- end the function here
end
end
UDF1.CEMemo2.Lines.Add(caption);
ListSave()
CreateFile()
showMessage("Code page successfully added to list!")
end |
|
Thanks @DaSpamer.
Again, the codes were created with the help of many masters,
but it gave good results for the archive.
I'il share this. (Of course, mentioning the contributors)
I'm gonna shoot a video.
I will then share the Lua extension.
_________________
|
|
Back to top |
|
|
|