home *** CD-ROM | disk | FTP | other *** search
/ Using Asymetrix Multimedi…ool Book Special Edition / SE_UAMT.iso / examples / ch16.tbk (.txt) < prev    next >
Encoding:
Asymetrix ToolBook File  |  1995-11-02  |  50.9 KB  |  720 lines

  1. CDBSE&File
  2. &Open...    Ctrl+O
  3. &Save    Ctrl+S
  4. Save &As...
  5. saveas
  6. &Import...
  7. import
  8. &Export...
  9. export
  10. Print Set&up...
  11. printsetup
  12. &Print Pages...    Ctrl+P
  13. printpages
  14. Prin&t Report...
  15. printreport
  16. Send &Mail...
  17. sendmail
  18. &Run...
  19. E&xit    Alt+F4
  20. &Edit
  21. &Undo    Ctrl+Z
  22. Cu&t    Ctrl+X
  23. &Copy    Ctrl+C
  24. &Paste    Ctrl+V
  25. paste
  26. C&lear    Del
  27. clear
  28. Select &All    Shift+F9
  29. selectall
  30. Select Pa&ge    Shift+F12
  31. selectpage
  32. &Size to Page    F11
  33. sizetopage
  34. F&ind...    F5
  35. Re&place...
  36. replace
  37. Aut&hor    F3
  38. author
  39. &Text
  40. &Character...    F6
  41. character
  42. &Paragraph...    F7
  43. paragraph
  44. &Regular    Ctrl+Space
  45. regular
  46. &Bold    Ctrl+B
  47. &Italic    Ctrl+I
  48. italic
  49. &Underline    Ctrl+U
  50. underline
  51. Stri&keout    Ctrl+K
  52. strikeout
  53. Superscrip&t/Subscript
  54. superscriptSubscript
  55. &Normal Script
  56. normalscript
  57. Su&bscript    Ctrl+L
  58. subscript
  59. Su&perscript    Ctrl+Shift+L
  60. superscript
  61. &Show Hotwords    F9
  62. showhotwords
  63. &Page
  64. &Next    Alt+Right
  65. &Previous    Alt+Left
  66. previous
  67. &First    Alt+Up
  68. first
  69. &Last    Alt+Down
  70. &Back    Shift+F2
  71. &History...    Ctrl+F2
  72. history
  73. N&ew Page    Ctrl+N
  74. newpage
  75. &Help
  76. &Contents    F1
  77. contents
  78. Status &Bar    F12
  79. statusbar
  80. ?benchmark
  81. buttonDown
  82. buttonUp
  83. buttonClick
  84. enterApplication
  85. leaveApplication
  86. enterBook
  87. leaveBook
  88. enterBackground
  89. leaveBackground
  90. enterPage
  91. leavePage
  92. keyDown
  93. keyUp
  94. firstIdle
  95. -$,    #?
  96. +',$!
  97. window bmp1 state maximized
  98. play bmp1
  99. status bmp1 window
  100. bDown
  101. scanning
  102. stoats8.bmp alias bmp1 style
  103. child parent
  104. EnterPage
  105. close all
  106. leavePage
  107. scanning
  108. location
  109. bDown
  110. .'+    +F
  111. scanning
  112. .'+    +F
  113. .'+    +F
  114. +#,"Y
  115. +#,"Y
  116. curLoc
  117. scanning
  118. location
  119. curLoc
  120. bmpLoc
  121. where bmp1 source wait
  122. +#,"Y
  123. +#,"Y
  124. status bmp1 position wait
  125. curLoc
  126. +#,"Y
  127. V,    #?
  128. +#,"Y
  129. V,    #>
  130. window bmp1 position
  131. bmpLoc
  132. That's a string.
  133. That's a negative number.
  134. That's a fraction.
  135. You have entered zero.
  136. Please enter a positive integer.
  137. iFactorial2
  138. TO GET iFactorial2 n
  139. ZREAL @result
  140. ZSTRING s
  141. ZLONG i
  142. xisType(
  143.             s = "That's a 
  144. 1INT,n) 
  145. n < 0
  146.             s = "
  147. 5negative 
  148. n = 0
  149.             s = "You have entered zero."
  150. "WORD",n)        
  151.             s = "
  152. fraction."
  153. s & CRLF & "Please 
  154.  a positive integer."
  155. keyDown
  156. TO HANDLE 
  157. ZLONG i, cc
  158. k <> keyEnter 
  159. = NULL
  160. cc = 
  161. = SPACE
  162. R(i + 1) 
  163.  cc = cc - 1
  164. Removes Double Spaces.
  165. Type in the field below, then press Enter:
  166. enterPage
  167. NOTIFYAFTER 
  168. TO GET iFactorial2 n
  169.     local REAL @result
  170.     local STRING s
  171.     local LONG i
  172.     conditions
  173.         when not isType(REAL,n)
  174.             s = "That's a string."
  175.             break conditions
  176.         when isType(INT,n) and n < 0
  177.             s = "That's a negative number."
  178.             break conditions
  179.         when n = 0
  180.             s = "You have entered zero."
  181.             break conditions
  182.         when not isType("WORD",n)        
  183.             s = "That's a fraction."
  184.             break conditions
  185.         else
  186.             @result = 1
  187.             step i from 1 to n 
  188.                 @result = @result * i
  189.             end step
  190.             return @result
  191.         end conditions
  192.         return s & CRLF & "Please enter a positive integer."
  193. END iFactorial2
  194. enterPage
  195. sdfg sf sf 'sdf sflg slfg sf;'l sflg sfdgllllll
  196. TO GET 
  197. z = (
  198. It) * xs
  199. z = (
  200. It) * ys
  201. TO SET 
  202. )/xs & "," \
  203. )/ys && "
  204. stoats
  205. stoats8.bmp
  206. \stoats8.
  207. <BookPath>
  208. :HDMEDIAPATH
  209. System
  210. Arial
  211. Pusharound
  212. Page 5
  213. Scroll
  214. Number of Colors Available
  215. Screen Resolution in Pixels
  216. enterPage
  217. TO HANDLE 
  218. B"sr" 
  219. = "Screen Resolution 
  220. Pixels"
  221. B"mc" 
  222. = "Number 
  223. Colors Available"
  224. Number of Colors Available
  225. displayBitsPerPixel
  226. rpdisplayBitsPerPixel
  227. TB30WIN.DLL
  228. buttonClick
  229. TO HANDLE buttonClick
  230. ZLONG p
  231. linkDLL "TB30WIN.
  232. INT displayBitsPerPixel()
  233. p = 2 ^ 
  234. unLinkDLL "
  235. = "Number 
  236. Colors Available"
  237. Number of Colors Available
  238. enterPage
  239. button
  240. buttonDown
  241. NOTIFYBEFORE 
  242. = NULL
  243. NOTIFYAFTER 
  244. 9verticalDisplayRes
  245. horizontalDisplayRes
  246. verticalDisplayRes
  247. Screen Resolution in Pixels
  248. TB30WIN.DLL
  249. horizontalDisplayRes
  250. buttonClick
  251. TO HANDLE buttonClick
  252. ZPOINT p
  253. linkDLL "TB30WIN.
  254. horizontalDisplayRes()
  255. 3verticalDisplayRes()
  256. :es()
  257. unLinkDLL "
  258. = "Screen Resolution 
  259. Pixels"
  260. Screen Resolution in Pixels
  261. enterPage
  262. buttonDown
  263. factorial
  264. Factorial
  265. TO GET Factorial n
  266. ZREAL @result
  267. ZLONG i
  268. xisType ("WORD", n)) 
  269. (n = 0)
  270. n = 1
  271. V = (factorial(n-1)) * n
  272. iterate
  273. enterPage
  274. NOTIFYAFTER 
  275. TO GET Factorial n
  276.      local REAL @result
  277.     local LONG i
  278.     if (not isType ("WORD", n)) or (n = 0)
  279.         return 0
  280.     end if
  281.     if n = 1
  282.         return 1
  283.     end if
  284.     @result = (factorial(n-1)) * n
  285.     return @result
  286. END factorialtoriallllll
  287. recurse
  288. enterPage
  289. NOTIFYBEFORE 
  290. TO GET factorial n
  291.     local REAL @result
  292.     local LONG i
  293.     if not isType ("WORD", n) or n = 0
  294.         return 0
  295.         
  296.     end if
  297.     @result = 1
  298.     step i from 1 to n 
  299.         @result = @result * i
  300.     end step
  301.     return @result
  302. END factoriallialloriallalalialialtoriallll
  303. factorial
  304. Invalid Entry. Please try again.
  305. keyDown
  306. TO HANDLE 
  307. ZSTRING s
  308. k <> keyEnter
  309. factorial (
  310. s = "Invalid Entry. Please 
  311. "f2" 
  312. Enter value,
  313. then press <ENTER>:
  314. 3628800 Entry. Please try again.L @result
  315.     local LONG i
  316.     if not isType ("WORD", n) or n = 0
  317.         return 0
  318.         
  319.     end if
  320.     @result = 1
  321.     step i from 1 to n 
  322.         @result = @result * i
  323.     end step
  324.     return @result
  325. END factorialrn @result
  326. END Factorial
  327. Answer:
  328. Get a Factorial!
  329. Select a method:
  330. iterate
  331. buttonClick
  332. TO HANDLE buttonClick
  333. "iterate" 
  334. Iterative
  335. recurse
  336. buttonClick
  337. TO HANDLE buttonClick
  338. "recurse" 
  339. Recursive
  340. enterPage
  341. buttonDown
  342. NOTIFYBEFORE 
  343. = NULL
  344. NOTIFYAFTER 
  345. enterPage
  346. buttonDown
  347. enterPage
  348. n @result
  349. END factorial
  350. enterPage
  351. buttonDown
  352. enterPage
  353. That's a string.
  354. That's a negative number.
  355. That's a fraction.
  356. You have entered zero.
  357. Please enter a positive integer.
  358. iFactorial2
  359. TO GET iFactorial2 n
  360. ZREAL @result
  361. ZSTRING s
  362. ZLONG i
  363. xisType(
  364.             s = "That's a 
  365. 1INT,n) 
  366. n < 0
  367.             s = "
  368. 5negative 
  369. n = 0
  370.             s = "You have entered zero."
  371. "WORD",n)        
  372.             s = "
  373. fraction."
  374. s & CRLF & "Please 
  375.  a positive integer."
  376. iFactorial2
  377. keyDown
  378. TO HANDLE 
  379. ZSTRING s
  380. k <> keyEnter
  381. iFactorial2 (
  382. "f2" 
  383. 5.0001
  384. Enter value,
  385. then press <ENTER>:
  386. That's a fraction.
  387. Please enter a positive integer.nteger.
  388. Answer:
  389. Get a Factorial!
  390. Use conditions.:
  391. enterPage
  392. NOTIFYAFTER 
  393. TO GET iFactorial2 n
  394.     local REAL @result
  395.     local STRING s
  396.     local LONG i
  397.     conditions
  398.         when not isType(REAL,n)
  399.             s = "That's a string."
  400.             break conditions
  401.         when isType(INT,n) and n < 0
  402.             s = "That's a negative number."
  403.             break conditions
  404.         when n = 0
  405.             s = "You have entered zero."
  406.             break conditions
  407.         when not isType("WORD",n)        
  408.             s = "That's a fraction."
  409.             break conditions
  410.         else
  411.             @result = 1
  412.             step i from 1 to n 
  413.                 @result = @result * i
  414.             end step
  415.             return @result
  416.         end conditions
  417.         return s & CRLF & "Please enter a positive integer."
  418. END iFactorial2
  419. enterPage
  420. That's a string.
  421. That's a negative number.
  422. That's a fraction.
  423. You have entered zero.
  424. Please enter a positive integer.
  425. iFactorial2
  426. TO GET iFactorial2 n
  427. ZREAL @result
  428. ZSTRING s
  429. ZLONG i
  430. xisType(
  431.             s = "That's a 
  432. 1INT,n) 
  433. n < 0
  434.             s = "
  435. 5negative 
  436. n = 0
  437.             s = "You have entered zero."
  438. "WORD",n)        
  439.             s = "
  440. fraction."
  441. s & CRLF & "Please 
  442.  a positive integer."
  443. keyDown
  444. TO HANDLE 
  445. ZLONG i, cc
  446. k <> keyEnter 
  447. = NULL
  448. cc = 
  449. = SPACE
  450. R(i + 1) 
  451.  cc = cc - 1
  452. Removes Double Spaces.
  453. Type in the field below, then press Enter:
  454. enterPage
  455. NOTIFYAFTER 
  456. TO GET iFactorial2 n
  457.     local REAL @result
  458.     local STRING s
  459.     local LONG i
  460.     conditions
  461.         when not isType(REAL,n)
  462.             s = "That's a string."
  463.             break conditions
  464.         when isType(INT,n) and n < 0
  465.             s = "That's a negative number."
  466.             break conditions
  467.         when n = 0
  468.             s = "You have entered zero."
  469.             break conditions
  470.         when not isType("WORD",n)        
  471.             s = "That's a fraction."
  472.             break conditions
  473.         else
  474.             @result = 1
  475.             step i from 1 to n 
  476.                 @result = @result * i
  477.             end step
  478.             return @result
  479.         end conditions
  480.         return s & CRLF & "Please enter a positive integer."
  481. END iFactorial2
  482. enterPage
  483. Stage Page
  484. Stage Page
  485. *ClassTbl*
  486. *ClassEntry*
  487. *PTABLE*
  488. *WINDOWSEG*
  489. *ICONRESTAB*
  490. *ICONRESSEG*
  491. *ICONRES*
  492. Background
  493. *OBJTABLE*
  494. *IDTABLE*
  495. *NAMETAB*
  496. Rectangle
  497. Ellipse
  498. RoundedRectangle
  499. Polygon
  500. IrregularPolygon
  501. AngledLine
  502. Curve
  503. PaintObject
  504. Picture
  505. Group
  506. Stage
  507. Button
  508. Viewer
  509. ComboBox
  510. Field
  511. RecordField
  512. Hotword
  513. *RHOTWORD*
  514. *TbxBase*
  515. <BookPath>
  516. :HDMEDIAPATH
  517. System
  518. Arial
  519. Number of Colors Available
  520. Screen Resolution in Pixels
  521. enterPage
  522. TO HANDLE 
  523. B"sr" 
  524. = "Screen Resolution 
  525. Pixels"
  526. B"mc" 
  527. = "Number 
  528. Colors Available"
  529. Number of Colors Available
  530. TB40WIN.DLL
  531. displayBitsPerPixel
  532. rpdisplayBitsPerPixel
  533. TB30WIN.DLL
  534. buttonClick
  535. TO HANDLE buttonClick
  536. ZLONG p
  537. linkDLL "TB40WIN.
  538. INT displayBitsPerPixel()
  539. p = 2 ^ 
  540. unLinkDLL "TB30WIN.
  541. = "Number 
  542. Colors Available"
  543. Number of Colors Available
  544. enterPage
  545. button
  546. buttonDown
  547. NOTIFYBEFORE 
  548. = NULL
  549. NOTIFYAFTER 
  550. TO HANDLE buttonClick
  551.     local LONG p
  552.     linkDLL "TB40WIN.DLL"
  553.         INT displayBitsPerPixel()
  554.     end linkDLL
  555.     p = 2 ^ displayBitsPerPixel()
  556.     unLinkDLL "TB30WIN.DLL"
  557.     caption of self = p
  558.     pause 3 seconds
  559.    caption of self = "Number of Colors Available"
  560. END buttonClicke 3 seconds
  561.     caption of self = "Screen Resolution in Pixels"
  562. END buttonClick
  563. TB40WIN.DLL
  564. 9verticalDisplayRes
  565. Screen Resolution in Pixels
  566. TB30WIN.DLL
  567. horizontalDisplayRes
  568. verticalDisplayRes
  569. horizontalDisplayRes
  570. buttonClick
  571. TO HANDLE buttonClick
  572. ZPOINT p
  573. linkDLL "TB40WIN.
  574. horizontalDisplayRes()
  575. 3verticalDisplayRes()
  576. :es()
  577. unLinkDLL "TB30WIN.
  578. = "Screen Resolution 
  579. Pixels"
  580. Screen Resolution in Pixels
  581. enterPage
  582. buttonDown
  583. TO HANDLE EnterPage
  584. 4LOGICAL scanning
  585. 4INT xs,ys
  586. 4DWORD hWnd
  587. --use the 
  588. 4property sysPageUnitsPerPixel 
  589. screen unit
  590. pixel conversions. You 
  591. s also 
  592. Uvarious 
  593. --functions.
  594. --Assign 
  595. _just 
  596. avoid having 
  597. so many
  598. %you enter 
  599. handlers
  600.     xs = 
  601.     ys = 
  602. --Initialize 
  603. " flag so that 
  604.  = FALSE
  605. --Establish 
  606. path 
  607. bitmap. In 
  608. assumed 
  609. same folder 
  610. <> "\"
  611. --Open 
  612. its display 
  613. " && 
  614. & "stoats8.bmp alias bmp1 style" \
  615. && "child 
  616. " && sysClientHandle && "wait")
  617. @ate maximized")
  618. ("status 
  619. --Translate messages 
  620. Windows operating 
  621. OpenScript 
  622. ToolBook 
  623. translateWindowMessage 
  624. on 513 
  625. bDown
  626. --513 
  627. sent on 
  628. Bdown
  629. on 514 
  630. --513 
  631. --Forward 
  632.  so higher levels receive 
  633.     unTranslateAllWindowMessages
  634. imageCommand("close 
  635. 4POINT location
  636. --This 
  637.  called 
  638. translated 
  639.  513.
  640. --It sets "
  641. " so 
  642. scroller operates
  643. establishes 
  644. initial mouse 
  645.  = TRUE
  646.  = mousePosition 
  647.  513.
  648. --It resets "
  649. " so 
  650. does 
  651.  will 
  652. appropriate
  653. --cursor 
  654. resume.
  655. !(hourglass)
  656. bmpOffset
  657. bmpSlop
  658. bmpLoc,newPos,currentLoc
  659. handled.
  660.  without processing 
  661. o<> 44
  662. o= 44
  663. a repeating 
  664. , so prevent flicker 
  665. --slowdown 
  666. Hsetting 
  667. only 
  668. needed. Use the
  669. --four-pointed 
  670. indicate 
  671. available:
  672. o<> 7
  673. how much 
  674. has been moved since
  675. It - 
  676. It - 
  677. amount 
  678. motion 
  679. --Each 
  680. , which represent width 
  681. height,
  682. --are computed 
  683. full 
  684. subtracted so 
  685. picture doesn't 
  686. --offscreen, 
  687. each 
  688. multiplied 
  689. twips per 
  690. . However, no stretching 
  691. shrinking
  692. --actually occurs 
  693. resolution 
  694. where 
  695. ource 
  696. It - 640) * xs
  697. It - 480) * ys
  698. --pixels 
  699.  = curLoc()
  700. --Calculate 
  701. V    points 
  702. --stop because 
  703. {    edge 
  704. meets the
  705.  ) <= 0 \
  706. ) <= 0 \
  707. ) > \
  708. ) > \
  709. --Update 
  710. account 
  711. a placeholder
  712. TO GET 
  713. z = (
  714. It) * xs
  715. z = (
  716. It) * ys
  717. TO SET 
  718. )/xs & "," \
  719. )/ys && "
  720.