Sver
Full Member
Posts: 145
|
Post by Sver on Jul 5, 2018 13:01:15 GMT -5
Is it possible to escape.
While ,,..
len input (when somebody change it/typing)
exit when trapclose
Wend
|
|
|
Post by Carl Gundel on Jul 5, 2018 15:12:08 GMT -5
Is it possible to escape.
While ,,..
len input (when somebody change it/typing)
exit when trapclose
Wend
Of course you can use EXIT WHILE to break out of the WHILE loop, but I'm not sure what you mean about trap close?
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Jul 6, 2018 1:34:01 GMT -5
With while/wend, i want to scan a textbox or somebody is typing/remove a letter, so the program can search again. When "lenght" is changed then,..
But it isn't possible to close the program. Red button/trapclose.
|
|
|
Post by tsh73 on Jul 6, 2018 3:33:31 GMT -5
So your problem probably that your WHILE loop does not leave Windows time to process messages.
Use TIMER instead of WHILE loop.
nomainwin
WindowWidth = 550 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
statictext #main.st1, "Change me", 6, 11, 144, 20 statictext #main.statictext2, "Look here", 6, 61, 144, 20 textbox #main.txt, 6, 31, 496, 25 texteditor #main.log, 6, 81, 520, 265 menu #main, "Edit" '<--- Texteditor Menu can be moved but not removed.
open "Close me" for window_nf as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10" oldTxt$=""
timer 100, [isChanged] 'check for changes every 100 ms. So Windows have time to process close button etc wait
[isChanged] #main.txt "!contents? txt$" 'get current text if txt$<>oldTxt$ then 'if text changed #main.log time$();">";txt$ oldTxt$=txt$ end if
wait
[quit.main] timer 0 'timer off, just for a case Close #main END
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Jul 6, 2018 9:29:39 GMT -5
Thanks ! Be honest, i used timer only for delay. The help file tells something about repeat, but whitout a short example. I can use it for a listbox with .txt file
It's simple to make a complex solution and complex to make a simple solution.
|
|
|
Post by Rod on Jul 6, 2018 15:17:23 GMT -5
If I get time I would like to experiment. But what I think is happening is that your while wend loop is generating many millions of len() checks because it hits SCAN and branches. Occasionally it hits X and puts that branch in the queue. The problem is it is running so fast, if you left it alone for a while it would eventually get to the X.
|
|
|
Post by Rod on Jul 7, 2018 5:01:53 GMT -5
This does something similar to what you describe. It uses a timer loop to check for changed input. The timer paces the loop so allowing Windows to handle other code.
dim array$(10) array$(1)="apple" array$(2)="car" array$(3)="cat" array$(4)="cement" array$(5)="dog" array$(6)="pavement" items=6 nomainwin WindowWidth = 500 WindowHeight = 400 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) statictext #main.search, "Enter your search", 80, 20, 244, 20 textbox #main.textbox, 80, 40, 300, 20 listbox #main.listbox, temparray$(), [update],80, 65, 300, 200 open "User Input" for window as #main #main "trapclose [quit]" #main.textbox "!setfocus" #main.listbox "singleclickselect"
timer 250, [search] wait
[search] timer 0 #main.textbox "!contents? text$" dim temparray$(items) found=1 for n= 1 to items if instr(array$(n),text$,1)>0 then temparray$(found)=array$(n) :found=found+1 next #main.listbox "reload" timer 250, [search] wait
[update] timer 0 #main.listbox "setfocus" #main.listbox "selectionindex? i" #main.listbox "selection? choice$" notice "You choose ";choice$
[quit] close #main end
|
|
Sver
Full Member
Posts: 145
|
Post by Sver on Jul 7, 2018 7:15:13 GMT -5
Ok, items=10 dim array$(items) array$(1)="apple" array$(2)="car" array$(3)="cat" array$(4)="cement" array$(5)="dog" array$(6)="pavement sort array$(),1,items 'Nomainw,....
items depending,.. lines(.txt) or records , it looks like a listdialog with searchbox Thanks !
|
|