1. Writing a stream of data to an EditText box

Thanks to Robert Craig for his comments about C programs displaying on full
screen.
I found a solution amongst the Troubleshoot section of the Manual.
Alt+Enter toggles between full screen and a window - simple!

Now for my latest problems:
How do you write a stream of data (atoms or integers) to an EditText box or
similar
control in Windows IDE (judith's).

In a simple example I want to write the results of a for...do loop
so that all the output is visible on the same line.

for x=1 to 10 do
setText(EditText1,x)
end for

Hoped for output would be 1  2  3  4  5  6 ... 10

I have also tried all permutations of wPuts(), wPrintf(), and wPrint() and the
best
I can achieve is for each number to overwrite the previous, ending up with 10.
I have also tried getScrollPos() and setScrollPos() to try to move the text
along a bit,
but no go. I suspect that EditText boxes do not have a cursor location facility.

What is the solution?

Second question.

In the progressbar.exw demo bundled with W32lib the output to the progress bar
is
setText(Gauge, sprintf("%d%% (%d)", sequence etc...

Can someone explain the format string?  %d I'm familliar with, but can't figure
out what the rest does,
particularily the (%d). It doesn't seem necessary as a simple "%d" works fine.

Again, any help gratefully received.

jaybeedee

new topic     » topic index » view message » categorize

2. Re: Writing a stream of data to an EditText box

JAYBEEDEE wrote:
> 
> Now for my latest problems:
> How do you write a stream of data (atoms or integers) to an EditText box or
> similar
> control in Windows IDE (judith's).
> 
> In a simple example I want to write the results of a for...do loop
> so that all the output is visible on the same line.
> 
> for x=1 to 10 do
> setText(EditText1,x)
> end for
> 
> Hoped for output would be 1  2  3  4  5  6 ... 10
> 
> I have also tried all permutations of wPuts(), wPrintf(), and wPrint() and the
> best
> I can achieve is for each number to overwrite the previous, ending up with 10.
> I have also tried getScrollPos() and setScrollPos() to try to move the text
> along a bit,
> but no go. I suspect that EditText boxes do not have a cursor location
> facility.
> 
> What is the solution?

When you call setText(), you're literally SETTING the text in the box, that's
it: whatever is there is replaced. You want to append text to the box, so use
appendText().

And get/setScrollPos() has no affect on a text box. See get/setIndex() for
cursor positioning.


> Second question.
> 
> In the progressbar.exw demo bundled with W32lib the output to the progress bar
> is
> setText(Gauge, sprintf("%d%% (%d)", sequence etc...
> 
> Can someone explain the format string?  %d I'm familliar with, but can't
> figure
> out what the rest does,
> particularily the (%d). It doesn't seem necessary as a simple "%d" works fine.
> 
> Again, any help gratefully received.

Special characters for printf() (and sprintf) are escaped by '%' and nothing
more. The parentheses will display as-is. The double '%' prints a literal '%' in
the string. That formatting would output something like this:

printf(1, "%d%% (%d)", {52, 37})
-- prints "52% (37)"




-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: Writing a stream of data to an EditText box

JAYBEEDEE wrote:
> 
> Thanks to Robert Craig for his comments about C programs displaying on full
> screen.
> I found a solution amongst the Troubleshoot section of the Manual.
> Alt+Enter toggles between full screen and a window - simple!
> 
> Now for my latest problems:
> How do you write a stream of data (atoms or integers) to an EditText box or
> similar
> control in Windows IDE (judith's).
> 
> In a simple example I want to write the results of a for...do loop
> so that all the output is visible on the same line.
> 
> for x=1 to 10 do
> setText(EditText1,x)
> end for
> 
> Hoped for output would be 1  2  3  4  5  6 ... 10
> 
> I have also tried all permutations of wPuts(), wPrintf(), and wPrint() and the
> best
> I can achieve is for each number to overwrite the previous, ending up with 10.
> I have also tried getScrollPos() and setScrollPos() to try to move the text
> along a bit,
> but no go. I suspect that EditText boxes do not have a cursor location
> facility.
> 
> What is the solution?
> 
> Second question.
> 
> In the progressbar.exw demo bundled with W32lib the output to the progress bar
> is
> setText(Gauge, sprintf("%d%% (%d)", sequence etc...
> 
> Can someone explain the format string?  %d I'm familliar with, but can't
> figure
> out what the rest does,
> particularily the (%d). It doesn't seem necessary as a simple "%d" works fine.
> 
> Again, any help gratefully received.
> 
> jaybeedee

sequence text text = {}

for x=1 to 10 do
text&= sprintf("%d ",{x}) -- note space so number won't run together
end for
-- set the edittext1 with the text sequence.
setText(EditText1,text)





Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

4. Re: Writing a stream of data to an EditText box

Thanks to Greg and Bernie.

Its so simple when you know how!

jaybeedee

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu