User Tools

Site Tools


incorporating_20bookmarks_20in_20a_20program

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
incorporating_20bookmarks_20in_20a_20program [2018/03/31 13:19] – external edit 127.0.0.1incorporating_20bookmarks_20in_20a_20program [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 4: Line 4:
 ==== Bookmarks using DEF ==== ==== Bookmarks using DEF ====
 \\  Normally you use **DEF** with the keywords **PROC** (to define a procedure) or **FN** (to define a function). However, if you include a line in your program which begins with **DEF** but is //not// followed by **PROC** or **FN** that line will act as a bookmark. For example:\\ \\  \\  Normally you use **DEF** with the keywords **PROC** (to define a procedure) or **FN** (to define a function). However, if you include a line in your program which begins with **DEF** but is //not// followed by **PROC** or **FN** that line will act as a bookmark. For example:\\ \\ 
 +<code bb4w>
         DEF _this_is_important_         DEF _this_is_important_
         REM important code starts here...         REM important code starts here...
 +</code>
 The name of the bookmark must follow normal procedure and function naming conventions, that is it must consist only of alphabetic characters (**A-Z**, **a-z**), digits (**0-9**) or the characters **_** (underscore), **@** (commercial-at) and **`** (backwards quote or grave accent).\\ \\  If you incorporate a space character in the bookmark the context menu will show only what precedes it, for example:\\ \\  The name of the bookmark must follow normal procedure and function naming conventions, that is it must consist only of alphabetic characters (**A-Z**, **a-z**), digits (**0-9**) or the characters **_** (underscore), **@** (commercial-at) and **`** (backwards quote or grave accent).\\ \\  If you incorporate a space character in the bookmark the context menu will show only what precedes it, for example:\\ \\ 
 +<code bb4w>
         DEF take me here         DEF take me here
 +</code>
 will result in **take** appearing in the menu.\\ \\  will result in **take** appearing in the menu.\\ \\ 
 ==== Bookmarks using labels ==== ==== Bookmarks using labels ====
 \\  You can incorporate [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin2.html#labelling|labels]] in your program, which are primarily intended to be used as the targets for **GOTO**, **GOSUB** or **RESTORE** statements (although their use is deprecated). However you can also use labels as bookmarks, for example:\\ \\  \\  You can incorporate [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwin2.html#labelling|labels]] in your program, which are primarily intended to be used as the targets for **GOTO**, **GOSUB** or **RESTORE** statements (although their use is deprecated). However you can also use labels as bookmarks, for example:\\ \\ 
 +<code bb4w>
         (_this_is_important_)         (_this_is_important_)
         REM important code starts here...         REM important code starts here...
 +</code>
 The same naming restrictions apply as with the previous method, and again if you incorporate a space character the context menu will show only what precedes it (in this case **take**):\\ \\  The same naming restrictions apply as with the previous method, and again if you incorporate a space character the context menu will show only what precedes it (in this case **take**):\\ \\ 
 +<code bb4w>
         (take me here)         (take me here)
 +</code>
 Using labels as bookmarks does have one minor disadvantage in that if you also use 'genuine' labels in your program (which hopefully you won't!) the bookmarks will use up some space on the heap, and could corrupt the value of a normal variable that happens to have the same name as the bookmark. A similar thing can happen if your program deliberately generates a **No such variable** error which is trapped, therefore allowing execution to continue.\\ \\  However these are unlikely circumstances and in most respects there is little to choose between the two methods of incorporating bookmarks. Using labels as bookmarks does have one minor disadvantage in that if you also use 'genuine' labels in your program (which hopefully you won't!) the bookmarks will use up some space on the heap, and could corrupt the value of a normal variable that happens to have the same name as the bookmark. A similar thing can happen if your program deliberately generates a **No such variable** error which is trapped, therefore allowing execution to continue.\\ \\  However these are unlikely circumstances and in most respects there is little to choose between the two methods of incorporating bookmarks.
incorporating_20bookmarks_20in_20a_20program.1522502365.txt.gz · Last modified: 2024/01/05 00:17 (external edit)