Forth Lesson 15/Example/Scope

From OLPC
< Forth Lesson 15
Revision as of 06:17, 11 October 2012 by Quozl (talk | contribs) (Created page with 'An example of how to use the scope keys. ''scan-wifi'' calls ''scan-subtree'', which calls ''wifi-children'' for each device node. : wifi-children " device_type" get-prop…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

An example of how to use the scope keys.

scan-wifi calls scan-subtree, which calls wifi-children for each device node.

: wifi-children 
   " device_type" get-property if
      exit 
   then
   get-encoded-string 
   " wireless-network" $= if
      " scan-wifi" method-name 2!            \ fda31c70 
      do-method? 
   then
;

Our goal is to step into the code inside the second if.

ok debug wifi-children
ok scan-wifi
  • first pass, the cursor will be on the first word, so step to the exit and press < to constrain the scope, then space to exit the definition,
  • second pass, the cursor will be on the get-encoded-string, so step to the second if and press < again to constrain the scope, then space until the definition exits,
  • third pass, the cursor will be on the ;, so press ) to constrain the end of the scope, then space to exit the definition.

On the fourth pass, the cursor will be on " scan-wifi" as desired.