|
Post by tsh73 on Aug 27, 2020 9:39:16 GMT -5
1) No I am don't know if it is possible to get handle$ with branch label handler (never heard of it, really suspect it is not possible) 2) all arrays in LB is global 3) Post your code. Describe how you want it to work. Probably folks will invent something - with things already in LB.
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 28, 2020 3:06:52 GMT -5
I just wanted to make A$=SearchValue$ outside of the SUN/CALL so that I can use it in a search function. Brandon suggested using 'byref' and although this command is accepted (as below) its not correct.
sub buttonClick handle$ SearchValue$=right$(handle$, 1) call assign A$ end sub
sub assign byref A$ A$=SearchValue$ end sub
|
|
|
Post by Chris Iverson on Aug 28, 2020 9:06:31 GMT -5
Are SearchValue$ and A$ global?
If not, that's why you're losing the data.
If SearchValue$ is not global, then the value is not available in the assign sub, so it assigns nothing to A$.
If A$ is not global, then the value is lost once buttonClick returns.
|
|
|
Post by tsh73 on Aug 28, 2020 16:43:44 GMT -5
That's no big deal Just declare SearchValue$ global, then it'll stay after firing sub buttonClick
The problem is - 1) you press a button, 2) sub buttonClick fire 3) it set SearchValue$ - if it is global it stays set 4) sub buttonClick quits. 5) PROBLEM: How you are going to start search? . You cannot GOTO [search] from withing the sub
It was said before - >> "Search" has to be converted to sub too >> (or do it just in this sub)
If it does not work post your code.
|
|
dkl
Full Member
Posts: 234
|
Post by dkl on Aug 28, 2020 19:34:05 GMT -5
Finally got it sorted......here is a modified version of the programme tsh73 posted, which incorporates a search OUTSIDE of the SUB/CALL by going to a Branch label after SearchValue$ has been assigned a value within the CALL/SUB
Thanks for all your help and patience!
' Form created with the help of Freeform-J v.261006 Dim B$(10) Global A$,SearchValue$ B$(1)="Apples" B$(2)="Cherries" B$(3)="Blueberries" B$(4)="Avocado" B$(5)="Acai" sch$="?" l=0 ' nomainwin
WindowWidth = 376 WindowHeight = 410
UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
button #main.A, "A", buttonClick, UL, 26, 20, 48, 25 button #main.B, "B", buttonClick, UL, 70, 20, 48, 25 button #main.C, "C", buttonClick, UL, 118, 20, 48, 25 button #main.Z, "Z", buttonClick, UL, 254, 20, 56, 25 button #main.srch, "SEARCH", [FIND], UL, 180, 45, 60, 20 statictext #main.statictext5, "log", 22, 46, 144, 20 statictext #main.statictext6, "Choose Value Then Click 'Search'....", 22, 0, 250, 20 texteditor #main.log, 22, 66, 320, 275 menu #main, "Edit" '<--- Texteditor Menu can be moved but not removed.
open "Push the button" for window as #main print #main, "trapclose [quit.main]"
print #main, "font ms_sans_serif 10"
wait
[quit.main] Close #main END
sub buttonClick handle$ SearchValue$=right$(handle$, 1) #main.log, "SearchValue$ ->";SearchValue$ call assign A$ end sub
sub assign byref A$ A$=SearchValue$ end sub
[FIND] print #main.log,"" print #main.log, "Let's Search Using ";A$ print #main.log,""
for lk=1 to 5 if left$(B$(lk),1) = A$ then print #main.log, B$(lk):nof=nof+1 next lk print #main.log,"" print #main.log, nof;" files found" print #main.log, "-----------------------" nof=0 wait
|
|