Re: Writing a stream of data to an EditText box
- Posted by Greg Haberek <ghaberek at gmail??om> Mar 03, 2008
- 590 views
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