View previous topic :: View next topic |
Author |
Message |
Autem Expert Cheater
Reputation: 1
Joined: 30 Jan 2023 Posts: 156
|
Posted: Tue Jun 10, 2025 2:31 pm Post subject: I can't get io.stdout:write to work... Any ideas? |
|
|
For the first time ever, I've been trying to utilize io.stdout:write ...but I'm not having any success, and I'm wondering what I may be doing wrong since I've never used it before.
When I open the LUA Engine and execute this as a test, nothing gets printed...
Code: | io.stdout:write("Hi") |
Based on suggestions I found when searching, I also have tried using io.flush() along with it, without success.
I'm wondering what I may be missing when it comes to using io.stdout:write instead of print? I need to print some lines without the default ending space/newline that "print" applies by default, and I thought io.stdout:write could be the solution.
Possible important detail: I will be running 2 instances of CE while using this, if that matters at all... however, even when I test using only 1 instance of CE, it still fails.
|
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 36
Joined: 16 Feb 2017 Posts: 1512
|
Posted: Tue Jun 10, 2025 4:25 pm Post subject: |
|
|
It promises to simply remove the extra space at the end of the line in the output of "print".
Use:
Code: | local output, exitCode = runCommand("cmd.exe", {"/C", "echo Hi World!"})
print("Command Output:", output) -- Redirecting through cmd |
_________________
|
|
Back to top |
|
 |
Autem Expert Cheater
Reputation: 1
Joined: 30 Jan 2023 Posts: 156
|
Posted: Wed Jun 11, 2025 2:25 pm Post subject: |
|
|
AylinCE wrote: | Code: | local output, exitCode = runCommand("cmd.exe", {"/C", "echo Hi World!"})
print("Command Output:", output) -- Redirecting through cmd |
|
This works great on one of the CE instances I run, but the second CE instance is an older version that doesn't support runCommand. Is there possibly a way to duplicate this result (no trailing space on print) on the older CE also, which is CE 6.5?
|
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 36
Joined: 16 Feb 2017 Posts: 1512
|
Posted: Thu Jun 12, 2025 3:58 am Post subject: |
|
|
I assume this will work on all CE versions.
Instead of "print()" for printing, you should use the "Lines.Add()" method.
The "Lines.Add()" method does not add a space at the end of the line.
It is easy to copy and print. (Lines.Text)
Code: | local obj = getLuaEngine()
local prtMemo
for i = 0, obj.ComponentCount - 1 do
if obj.Component[i].className=='TMemo' then
prtMemo = obj.Component[i]
print("Output name: "..obj.Component[i].Name) -- 7.5..>mOutput
end
end
prtMemo.Lines.Add("Hello CE")
prtMemo.Lines.Add("Hello CE..1")
prtMemo.Lines.Add("Hello CE..2")
text = prtMemo.Lines.Text
print(text) |
And this is the "print()" method:
Code: | local obj = getLuaEngine()
local prtMemo
for i = 0, obj.ComponentCount - 1 do
if obj.Component[i].className=='TMemo' then
prtMemo = obj.Component[i]
--print("Output name: "..obj.Component[i].Name) -- 7.5..>mOutput
end
end
local print = function(s) return prtMemo.Lines.Add(s) end
print("Hello CE")
print("Hello CE..1")
print("Hello CE..2")
print("<<<--->>>")
text = prtMemo.Lines.Text
print(text) |
_________________
|
|
Back to top |
|
 |
Autem Expert Cheater
Reputation: 1
Joined: 30 Jan 2023 Posts: 156
|
Posted: Thu Jun 12, 2025 11:55 am Post subject: |
|
|
Both of these methods you supplied are working great on older versions I tested. This is a fantastic workaround to avoid those white spaces everywhere. Thank you very much for your help and creativity with this!
|
|
Back to top |
|
 |
|