Author |
Topic: Handle variables in maphandle (Read 118 times) |
|
k6dgw
New Member
member is offline
Gender:
Posts: 6
|
|
Handle variables in maphandle
« Thread started on: Mar 6th, 2018, 10:47pm » |
|
Are handle variables valid in maphandle?
textbox #X.tmp, x, y, w, h newh$="#Win.rc"+str$(row)+str$(col) maphandle #X.tmp #newh$
gives me a type mismatch on the maphandle line
Fred
|
|
Logged
|
Fred Sparks NV USA
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Handle variables in maphandle
« Reply #1 on: Mar 7th, 2018, 08:33am » |
|
on Mar 6th, 2018, 10:47pm, k6dgw wrote:Are handle variables valid in maphandle? |
|
Of course; in fact MAPHANDLE would hardly be useful at all if that wasn't the case. The error in your code is that you have a spurious hash symbol prefixing the second parameter; it should be:
Code: textbox #X.tmp, x, y, w, h
newh$="#Win.rc"+str$(row)+str$(col)
maphandle #X.tmp, newh$ The two forms of MAPHANDLE are:
Code: MAPHANDLE #oldhandle, #newhandle
MAPHANDLE #oldhandle, newhandle$ Richard.
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Handle variables in maphandle
« Reply #2 on: Mar 7th, 2018, 12:02pm » |
|
Fred is thinking about the #handleVariable concept.
Code:nomainwin
textbox #t.txt, 20, 40, 260, 25
WindowWidth = 350 : WindowHeight = 190
open "Simple text box" for window as #t
#t "trapclose [quit]"
h$="#t.txt"
#h$ "hello"
new$="#t.txt2"
maphandle #t.txt, #new$
#new$ "again"
wait
[quit]
close #t
end
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Handle variables in maphandle
« Reply #3 on: Mar 7th, 2018, 12:49pm » |
|
on Mar 7th, 2018, 12:02pm, Rod wrote:Fred is thinking about the #handleVariable concept. |
|
It's true that LB is somewhat inconsistent in its handle variable syntax, which is probably what led him astray. When you are accessing a control using a handle variable you must add a hash prefix:
Code: #handlevariable$ "Command string" (this means you effectively have two hashes: an explicit one as shown and another in the handle variable string).
However in the MAPHANDLE statement you must not add a hash prefix to the handle variable:
Code: MAPHANDLE #oldhandle, newhandle$ Although this is clearly documented in the LB help file, the inconsistency could usefully be highlighted to reduce the likelihood of mistakes.
Richard.
|
|
Logged
|
|
|
|
k6dgw
New Member
member is offline
Gender:
Posts: 6
|
|
Re: Handle variables in maphandle
« Reply #4 on: Mar 12th, 2018, 9:58pm » |
|
Thank you both! It's always the little things that confuse me.
|
|
Logged
|
Fred Sparks NV USA
|
|
|
|