Post by Walt Decker on Dec 27, 2022 17:11:56 GMT -5
TAGS
---------
Tags are handy critters. Although tags are NOT LB "COMMANDS", LB uses them extensively. With the exception of menus, every LB event that is defined as a SUB rather than a label uses a tag as one of its arguments. SUB events that are associated with a graphic control, i. e. GRAPHICSBOX, GRAPHICS window, use a tag as its first argument.
If you are not familiar with SUB/FUNCTION usage the arguments are those parameters that follow the SUB/FUNCTION declaration:
SUB FOO Hndl, Id, Txt$
FUNCTION FOO.TOO(Hndl, Id, Txt$)
WHAT ARE THEY?
--------------
A tag is mearly a way to refer to some object. Every array and variable defined in an application is a tag, that is, a way to refer to a memory object, actually the address in memory of a large or small block of memory.
Every form and control defined in an application has a tag. For example:
CHECKBOX #DMY.CHKOPN, ......... <--- #DMY.CHKOPN is the tag
GRAPHICBOX #DMY.GFX, ........ <--- #DMY.GFX is the tag
OPEN "FOO" FOR WINDOW AS #DMY <--- #DMY is the tag
Reading/writing to a file is defined with a tag:
OPEN "FOO" FOR INPUT AS #1 <--- #1 is the tag
Loading, drawing, getting, saving, and destroying a bitmap requites a tag:
LOADBMP "MyBMP", BmpPath$ <--- MyBMP is the tag
PRINT #DMO.GFX, "drawbmp MyBMP 0 0"
PRINT #DMO.GFX, "getbmp YourBMP 0 0 200 300" <--- YourBMP is the tag
BMPSAVE "YourBMP", BmpPath$ <--- YourBMP is the tag
UNDLOADBMP "YourBMP" <--- YourBMP is the tag
The above tags contain a number. In the case of forms and controls it is the handle returned to LB by the operating system when the form or control is created. In the case of bitmaps it is the handle of a memory bitmap returned by the operating system when the bitmap is created.
SO WHAT?
--------
In LB the tag can be placed in a string variable and referred to with the string variable rather than the literal tag. For example:
Chk$ = "#DMO.CHKOPN"
#Chk$, "value? result$"
Gfx$ = "#DMO.GFX"
#Gfx$, "down"
Tag$ = "MyBMP"
LOADBMP Tag$, BmpPath$
When control events are defined as SUBs one can use the same SUB for controls of the same type and determine from the tag passed to the sub which control is activated:
'
The same type of thing can be done with forms and graphics. By setting up SUB/FUNCTIONS one can use one for almost any operation.
---------
Tags are handy critters. Although tags are NOT LB "COMMANDS", LB uses them extensively. With the exception of menus, every LB event that is defined as a SUB rather than a label uses a tag as one of its arguments. SUB events that are associated with a graphic control, i. e. GRAPHICSBOX, GRAPHICS window, use a tag as its first argument.
If you are not familiar with SUB/FUNCTION usage the arguments are those parameters that follow the SUB/FUNCTION declaration:
SUB FOO Hndl, Id, Txt$
FUNCTION FOO.TOO(Hndl, Id, Txt$)
WHAT ARE THEY?
--------------
A tag is mearly a way to refer to some object. Every array and variable defined in an application is a tag, that is, a way to refer to a memory object, actually the address in memory of a large or small block of memory.
Every form and control defined in an application has a tag. For example:
CHECKBOX #DMY.CHKOPN, ......... <--- #DMY.CHKOPN is the tag
GRAPHICBOX #DMY.GFX, ........ <--- #DMY.GFX is the tag
OPEN "FOO" FOR WINDOW AS #DMY <--- #DMY is the tag
Reading/writing to a file is defined with a tag:
OPEN "FOO" FOR INPUT AS #1 <--- #1 is the tag
Loading, drawing, getting, saving, and destroying a bitmap requites a tag:
LOADBMP "MyBMP", BmpPath$ <--- MyBMP is the tag
PRINT #DMO.GFX, "drawbmp MyBMP 0 0"
PRINT #DMO.GFX, "getbmp YourBMP 0 0 200 300" <--- YourBMP is the tag
BMPSAVE "YourBMP", BmpPath$ <--- YourBMP is the tag
UNDLOADBMP "YourBMP" <--- YourBMP is the tag
The above tags contain a number. In the case of forms and controls it is the handle returned to LB by the operating system when the form or control is created. In the case of bitmaps it is the handle of a memory bitmap returned by the operating system when the bitmap is created.
SO WHAT?
--------
In LB the tag can be placed in a string variable and referred to with the string variable rather than the literal tag. For example:
Chk$ = "#DMO.CHKOPN"
#Chk$, "value? result$"
Gfx$ = "#DMO.GFX"
#Gfx$, "down"
Tag$ = "MyBMP"
LOADBMP Tag$, BmpPath$
When control events are defined as SUBs one can use the same SUB for controls of the same type and determine from the tag passed to the sub which control is activated:
'
CHECKBOX #DMO.CHKCLR, "Select Color", CHK.COLOR, CHK.COLOR, X, Y, Wide, High
CHECKBOX #DMO.CHKUSE, "Use Last", CHK.COLOR, CHK.COLOR, X, Y, Wide, High
SUB CHK.COLOR ChkHndl$
IsSet$ = ""
#ChkHndl$, "VALUE? IsSet"
SELECT CASE ChkHndl$
CASE "#DMO.CHKCLR"
IF IsSet$ = "set" THEN
END IF
CASE "#DMO.CHKUSE"
IF IsSet$ = "set" THEN
END IF
END SELECT
END SUB
'
The same type of thing can be done with forms and graphics. By setting up SUB/FUNCTIONS one can use one for almost any operation.