home *** CD-ROM | disk | FTP | other *** search
/ stazsoftware.com / www.stazsoftware.com.tar / www.stazsoftware.com / futurebasic / faq.php?v=0.orig < prev    next >
Text File  |  2010-08-22  |  13KB  |  392 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title>Staz Software</title>
  5. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  6. <style type="text/css">
  7.  
  8. body{
  9. background-color: #365488;
  10. border-top: 20px solid #365488;
  11. margin: 0px;
  12. }
  13.  
  14. a{
  15. color: #00f;
  16. text-decoration: none;
  17. }
  18.  
  19. a:hover{
  20. color: #00f;
  21. text-decoration: underline;
  22. }
  23.  
  24. p{
  25. margin: 0px;
  26. padding-left: 0px;
  27. padding-top: 0px;
  28. padding-right: 0px;
  29. padding-bottom: 10px;
  30. }
  31.  
  32. h1{
  33. font-size: 23px;
  34. padding-left: 2px;
  35. padding-top: 4px;
  36. padding-right: 5px;
  37. padding-bottom: 2px;
  38. margin-left: -2px;
  39. margin-top: 0px;
  40. margin-right: 0px;
  41. margin-bottom: 10px;
  42. background-color: #e7edf6;
  43. }
  44.  
  45. h2{
  46. font-size: 19px;
  47. padding: 0px;
  48. padding: 0px;
  49. margin-left: 0px;
  50. margin-top: 0px;
  51. margin-right: 0px;
  52. margin-bottom: 10px;
  53. }
  54.  
  55. h3{
  56. font-size: 15px;
  57. padding: 0px;
  58. margin-left: 0px;
  59. margin-top: 0px;
  60. margin-right: 0px;
  61. margin-bottom: 10px;
  62. }
  63.  
  64. hr{
  65. background-color: #b7bbc2;
  66. height: 1px;
  67. border: 0px;
  68. margin-top: 0px;
  69. margin-left: 0px;
  70. margin-bottom: 10px;
  71. margin-right: 0px;
  72. padding: 0px;
  73. }
  74.  
  75. span#pre,span.pre{
  76. color: #996633;
  77. font-size: 12px;
  78. font-family: monospace;
  79. }
  80.  
  81. pre{
  82. color: #996633;
  83. font-size: 12px;
  84. font-family: monospace;
  85. padding: 0;
  86. margin-left: 0px;
  87. margin-top: 0px;
  88. margin-right: 0px;
  89. margin-bottom: 10px;
  90. }
  91.  
  92. table.w{
  93. background-image: url('../graphics/site/window/middle.png');
  94. background-repeat: repeat-y;
  95. width: 880px;
  96. margin-left: auto;
  97. margin-right: auto;
  98. }
  99.  
  100. td.w-top{
  101. background-image: url('../graphics/site/window/top.png');
  102. background-repeat: no-repeat;
  103. padding-left: 15px;
  104. padding-right: 15px;
  105. text-align: center;
  106. height: 60px;
  107. min-height: 60px;
  108. font-size: 1px;
  109. line-height: 1px;
  110. }
  111.  
  112. td.w-middle{
  113. padding-top: 0px;
  114. padding-left: 15px;
  115. padding-right: 15px;
  116. vertical-align: top;
  117. }
  118.  
  119. td.w-bottom{
  120. background-image: url('../graphics/site/window/bottom.png');
  121. background-repeat: no-repeat;
  122. height: 25px;
  123. min-height: 25px;
  124. }
  125.  
  126. table.w-content{
  127. float: left;
  128. clear: none;
  129. border: 10px solid #e7edf6;
  130. width: 650px;}
  131.  
  132. td.w-content{
  133. border-left: 1px solid #cfd4dc;
  134. border-top: 1px solid #cfd4dc;
  135. border-right: 1px solid #b7bbc2;
  136. border-bottom: 1px solid #b7bbc2;
  137. padding-left: 20px;
  138. padding-top: 20px;
  139. padding-right: 20px;
  140. padding-bottom: 10px;
  141. background-color: #fff;
  142. vertical-align: top;
  143. min-height: 500px;
  144. }
  145.  
  146. table.w-sidebar{
  147. border-top: 10px solid #e7edf6;
  148. border-right: 10px solid #e7edf6;
  149. border-bottom: 10px solid #e7edf6;
  150. background-color: #e7edf6;
  151. width: 199px;
  152. float: right;
  153. clear: none;
  154. }
  155.  
  156. td.w-sidebar{
  157. border-left: 1px solid #cfd4dc;
  158. border-top: 1px solid #cfd4dc;
  159. border-right: 1px solid #b7bbc2;
  160. border-bottom: 1px solid #b7bbc2;
  161. background-color: #fff;
  162. text-align: center;
  163. padding-left: 10px;
  164. padding-top: 20px;
  165. padding-right: 10px;
  166. padding-bottom: 10px;
  167. }
  168.  
  169. td.w-sidebar img{
  170. border: 0px;
  171. }
  172.  
  173. table.w-tabs{
  174. background-image: url('../graphics/site/tabs/background.png');
  175. background-position: bottom center;
  176. height: 40px;
  177. margin-top: auto;
  178. }
  179.  
  180. td.w-tabs{
  181. text-align: center;
  182. vertical-align: bottom;
  183. }
  184.  
  185. td.w-tabs img{
  186. border: 0px;
  187. }
  188.  
  189. td.w-tabs a{
  190. border: 0px;
  191. }
  192.  
  193. input.text-box{
  194. border-left: 1px solid #b7bbc2;
  195. border-top: 1px solid #b7bbc2;
  196. border-right: 1px solid #cfd4dc;
  197. border-bottom: 1px solid #cfd4dc;
  198. background-color: #fff;
  199. }
  200.  
  201. input.push-button{
  202. border-left: 1px solid #cfd4dc;
  203. border-top: 1px solid #cfd4dc;
  204. border-right: 1px solid #b7bbc2;
  205. border-bottom: 1px solid #b7bbc2;
  206. background-color: #fff;
  207. }
  208. </style>
  209. </head>
  210. <body>
  211. <table class="w" border="0" cellpadding="0" cellspacing="0">
  212. <tr>
  213. <td class="w-top">
  214.  
  215. <img src="../graphics/site/window/title.png" alt="Staz Software">
  216. <table class="w-tabs" border="0" cellpadding="0" cellspacing="0" width="100%">
  217. <tr>
  218. <td class="w-tabs"><a href="../index.php"><img src="../graphics/site/tabs/home.png" alt="Home"></a><a href="../futurebasic/index.php"><img src="../graphics/site/tabs/active-futurebasic.png" alt="FutureBasic"></a><a href="../shareware/index.php"><img src="../graphics/site/tabs/shareware.png" alt="Shareware"></a><a href="../order/index.php"><img src="../graphics/site/tabs/order.png" alt="Order"></a><a href="../contact/index.php"><img src="../graphics/site/tabs/contact.png" alt="Contact"></a></td>
  219. </tr>
  220. </table>
  221. </td>
  222. </tr>
  223.  
  224. <tr>
  225. <td class="w-middle">
  226.  
  227. <table class="w-content" border="0" cellpadding="0" cellspacing="0">
  228. <tr>
  229. <td class="w-content">
  230. <h1>FAQs</h1><h2>How do I add new toolbox calls?</h2><p>FB contains the calls necessary to create toolbox procedures and functions for standard routines and for library routines.</p>
  231.  
  232. <p>FB uses a syntax that is very similar to that of C when defining toolboxes (except that it is really much easier). FB also has the unique ability to offer aliases to toolbox calls. When Apple changes the name of a Toolbox routine, you can build a simple <span class="pre">TBALIAS</span> and use either the new or the old syntax.</p>
  233.  
  234. <pre>TOOLBOX FN Name(parameters) = result ` 68K code</pre>
  235.  
  236. <span class="pre">TOOLBOX</span> is a keyword that tells FB to add the following information to its list of toolbox routines.</p>
  237.  
  238. <p>FN means that this routine will return a result. If you are building a routine for a procedure, you eliminate this word. If this is a FN, the line must also contain the "<span class="pre">= result</span>" portion.</p>
  239.  
  240. <p>Name is case sensitive. It is one of the few things in FB that must exactly match Apple’s upper and lower case designations. If you don’t get this right, the PPC version of your application will crash when the toolbox is used.</p>
  241.  
  242. <p>68K code is taken directly from the headers supplied by Apple. This code is prefaced with the grave symbol (<span class="pre"> ` </span>) which is also called the back apostrophe by programmers.</p>
  243.  
  244. <h3>TOOLBOX procedure</h3>
  245.  
  246. <p>A procedure may have parameters (or not). It does not return a value. This first example shows a very simple conversion from a C headers file.</p>
  247.  
  248. <pre>
  249. PenNormal (void) ONEWORDINLINE(0xA89E);
  250. </pre>
  251. In FB, the translation is very easy.
  252. <pre>
  253. TOOLBOX PenNormal `0xA89E
  254. </pre>
  255.  
  256. <p>Parameters add another layer of complexity. Understanding what type of variable is to be passed can sometimes be difficult.</p>
  257.  
  258. <pre>
  259. PenSize(short width,short height)
  260.         ONEWORDINLINE(0xA89B);
  261. </pre>
  262.  
  263. <p>In C-dom, two or more words are used to describe parameters. The first word tells the size of the value required. The word "<span class="pre">short</span>" indicates that an integer is to be used. The word "<span class="pre">width</span>" is just an assigned variable name. This one is also easy to translate.</p>
  264.  
  265. <pre>
  266. TOOLBOX PenSize(SHORT,SHORT) `0A89B
  267. </pre>
  268. A byte, an integer (a short), or a long integer can be passed to the toolbox on the stack or in a register. When parameters are more than 4 bytes (the size of a long integer) then a pointer to the record is passed. As an example, a rectangle takes up 8 bytes in memory. Since we can’t pass something that large on the stack, it is necessary to pass its address as a pointer.</p>
  269.  
  270. <p>FB has a special syntax for this type of parameter. It uses the <span class="pre">@</span> symbol in the parameter list to indicate that the address of a variable, rather than the contents of a variable, should be passed to a toolbox routine.</p>
  271.  
  272. <pre>
  273. FrameRect(const Rect * r)
  274.           ONEWORDINLINE(0xA8A1);
  275. </pre>
  276.  
  277. <p>There is a difference here that is easy to spot. The "<span class="pre">r</span>" variable is preceded by a star. In C-speak, this is very similar to FB’s <span class="pre">@</span> symbol. The translated toolbox call can also handle these parameters.</p>
  278.  
  279. <pre>
  280. TOOLBOX FrameRect(@INT) `0xA8A1
  281. </pre>
  282.  
  283. <p>If the parameter type is defined (as is the case with RECT), you may optionally duplicate C’s syntax as follows:</p>
  284.  
  285. <pre>
  286. TOOLBOX FrameRect(const RECT *r) `0xA8A1
  287. </pre>
  288.  
  289. <p>FB is smart enough to know that the <span class="pre">@</span> symbol forces a long integer pointer. So using <span class="pre">@INT</span> means that a parameter is being passed which probably starts as an integer (but does not have to). FB passes the address of the integer (or long, or record) rather than the contents of that structure.</p>
  290.  
  291. <p>There is one exception to these rules:</p>
  292.  
  293. <p>If you use the C syntax of assigning a variable, then you must use the C syntax of a star (or asterisk) as the pointer. Either of the following would be acceptable.</p>
  294.  
  295. <pre>
  296. TOOLBOX FN GraphicsImportSetBoundsRect(¬
  297.      GraphicsImportComponent ci,¬
  298.      const RECT *bounds) ¬
  299.    = ComponentResult ¬
  300.     `0x2F3C, 0x0004, 0x0014, 0x7000, 0xA82A
  301.  
  302. TOOLBOX FN GraphicsImportSetBoundsRect(¬
  303.      GraphicsImportComponent ci,¬
  304.      @INT) ¬
  305.    = ComponentResult  ¬
  306.     `0x2F3C, 0x0004, 0x0014, 0x7000, 0xA82A
  307. </pre>
  308.  
  309. <p>The only difference between a function and a procedure is that a function returns a result. This result is either a byte, an integer, or a long integer. (You can’t return string results in toolbox calls.)</p>
  310.  
  311. <pre>
  312. EXTERN_API( RgnHandle )
  313. NewRgn (void) ONEWORDINLINE(0xA8D8);
  314. </pre>
  315.  
  316. <p>There are only two additions that we need to make in order to work with a toolbox function. The first is the addition of the term "<span class="pre">FN</span>" into the toolbox definition and the second is the use of the size of the result variable.</p>
  317.  
  318. <pre>
  319. TOOLBOX FN NewRgn = LONG `0xA8D8
  320. </pre>
  321.  
  322. <h3>TBALIAS</h3>
  323.  
  324. <p>The name of a toolbox call is often changed to make it easier to understand and use. As one example, Apple changed one toolbox name from <span class="pre">GetDItem</span> to <span class="pre">GetDialogItem</span>. We can tell FB that we want to be able to use either of these calls via the <span class="pre">TBALIAS</span> statement.</p>
  325.  
  326. <pre>
  327. TBALIAS GetDialogItem,GetDItem
  328. </pre>
  329.  
  330. <p>The first parameter (<span class="pre">GetDialogItem</span>) must be defined before the <span class="pre">TBALIAS</span> statement is encountered. This is the toolbox that was actually defined in FB. You could easily make up your own name for a toolbox call. The following would work just as well.</p>
  331.  
  332. <pre>
  333. TBALIAS GetDialogItem,GoAndFetchThatItem
  334. </pre>
  335.  
  336. <h3>LIBRARY</h3>
  337.  
  338. <p>The most common toolboxes are available as part of the system software. Other calls are loaded from shared libraries which are located in the extension folder, the application folder, or embedded in the application itself. This is how you would define a toolbox routine that is embedded in a library.</p>
  339.  
  340. <pre>
  341. Library "AppearanceLib"
  342. TOOLBOX FN RegisterAppearanceClient = SHORT ...
  343. TOOLBOX FN UnregisterAppearanceClient = SHORT ...
  344. ... more toolbox definitions here...
  345. LIBRARY
  346. </pre>
  347.  
  348. <p>The first <span class="pre">LIBRARY</span> statement tells FB to get information from the library named "<span class="pre">AppearanceLib</span>". After that, all toolbox calls from that library are defined. The final <span class="pre">LIBRARY</span> call tells FB to return to the standard library that was previously in use.</p>
  349.  
  350. </td>
  351. </tr>
  352. </table>
  353.  
  354. <table class="w-sidebar" border="0" cellpadding="0" cellspacing="0">
  355. <tr>
  356. <td class="w-sidebar">
  357. <p><a href="index.php"><img src="../graphics/fb_icon.png" alt="FutureBASIC"></a></p>
  358.  
  359. <p><a href="demo.php">Demo</a></p>
  360.  
  361. <p><a href="../order/index.php">Order</a></p>
  362.  
  363. <p><a href="tour.php">Tour</a></p>
  364.  
  365. <p><a href="tech-notes.php">Tech Notes</a></p>
  366.  
  367. <p><a href="faq.php">FAQ</a></p>
  368.  
  369. <p><a href="sample-code.php">Sample Code</a></p>
  370.  
  371. <p><a href="web-sites.php">Web Sites</a></p>
  372.  
  373. <p><a href="mailing-list.php">Mailing List</a></p>
  374.  
  375. <p><a href="system-requirements.php">System<br>Requirements</a></p>
  376.  
  377. <form method="GET" action="http://www.google.com/search" style="margin: 0; padding: 0;">
  378. <p style="margin: 0; padding: 0 0 5px 0; text-align: right;"><input type="hidden" id="ie" name="ie" value=UTF-8><input type="hidden" id="oe" name="oe" value=UTF-8><input type="text" name="q" size="15" maxlength="255" value="" style="width: 155px;" class="text-box"></p>
  379. <p style="margin: 0; padding: 0; text-align: right;"><input type="submit" name="btnG" value="Search" class="push-button"><input type="hidden" name="domains" value="stazsoftware.com"><input type="hidden" name="sitesearch" value=""><input type="hidden" name="sitesearch" value="stazsoftware.com" checked></p>
  380. </form></td>
  381. </tr>
  382. </table>
  383. </td>
  384. </tr>
  385.  
  386. <tr>
  387. <td class="w-bottom"><img src="../graphics/site/blank.gif" width="2" height="2" alt="blank"></td>
  388. </tr>
  389. </table>
  390.  
  391. </body>
  392. </html>