Smart Mobile Studio Version Differences
In Version 2.2 of Smart Mobile Studio, the units are external by default. This means that if you (1) keep your projects in the same folder, (2) do not change the default unit name from Unit1 and (3) do not heed the warning then you will overwrite the unit of another project when you save the current project. In order to save the Unit1 contents instead within the .dproj project file, right click on Unit1 in the Project Manager and select the option Make Item Internal.
Version 2.1 has newly named inbuilt units and in a canvas game application the class TApplication becomes TCanvasProject. Some of our existing demonstrations and programs use the old unit names and our new ones and revisions were developed using Version 2.1 or later.
If you are still using Version 2.0 and want to use code from new demonstrations, start a new project of the appropriate type and copy variable declarations and bodies of procedures from the demonstrations into the corresponding places in your new project. You must keep the old names of inbuilt units in the uses clause.
If you are using Version 2.1 and want to use demonstration code from an earlier version, follow these steps (which use Motion1 as an example).
- Start a new Canvas Project.
- Select menu item .
- Save the project as ProjectMotion1.sprog
- Select menu item .
- Save the file as Motion1.pas.
- Select the contents with CTRL+A.
- Select the code of Motion1 and copy it with CTRL+C.
- Paste the copied code into the Smart Mobile Studio editor to replace the existing code (CTRL+V).
- Compile the project (CTRL+F9) to highlight 2 errors in the application page:
Errors in Application Unit
- If necessary, change the first line to uses Motion1 as shown in the screenshot.
- Change TCanvasProject to TApplication (as it was in Version 2.0) in both places.
- Execute the project (F9).
If you have problems with compilation, another approach is to open ProjectMotion1.sprog in a text editor such as Notepad++ and look for any inconsistencies in names of variables, classes and files.
Either ignore any messages such as Warning: "W3GameApp" has been deprecated: Use SmartCL.GameApp instead or change the unit names as instructed.
We are now producing demonstrations with Version 3.0 of Smart Mobile Studio. See the new pages Using a TW3Image to Display Photographs and Using Two Shader Programs and several additions to WebGL pages. We have been able to provide alternative code for use with Version 3.0 where necessary for all of the student Smart Pascal programs and for most of our tutorial examples. Common alterations required are:
- the addition of System.Types.Graphics to the uses clause for the definition of TPoint and TRect;
- the addition System.Types (which sets the value 0f MAX_INT) to the uses clause;
- the addition of System.Time to the uses clause for the definition of TW3Timer;
- the addition of a parameter (usually Self), to call the create constructor of a TW3Timer;
- the assignment of font styles to Canvas.FontStyle rather than to Canvas.Font;
- new code to process key presses based on the supplied demo Tetris;
The following page shows the code of all of the files needed to compile a bare forms project with external form and unit files with the command line compiler of Version 3.0. The subsequent page shows the code of a trimmed-down single project file that contains all the data needed for a bare form.
Visual Components Project
Those of you interested in 3D graphics should note that the old W3C.WebGL unit becomes Khronos.WebGL. See this section of Displaying a Rectangle for WebGL code to go with the new TW3WebGL component.
The remainder of this page gives specific examples of changes to the code of Unit 1.
Canvas Game Application
It is important to note that the class TApplication in Version 2 becomes TCanvasProject in Version 2.1. This means that, if you do not edit the application unit as described in Step 11 above, the procedure names in the implementation section must have the prefix TCanvasProject. instead of TApplication.
// Version 2.0 uses W3System, W3Components, W3Application, W3Game, W3GameApp, W3Graphics; type TApplication = class(TW3CustomGameApplication) // Versions 2.1 and 3.0 Canvas Project uses System.Types, SmartCL.System, SmartCL.Components, SmartCL.Application, SmartCL.Game, SmartCL.GameApp, SmartCL.Graphics; type TCanvasProject = class(TW3CustomGameApplication)
// Version 2.0 uses W3System, W3Scroll, W3Console, W3Components, W3Application, W3ConsoleApp, W3Lists; type TApplication = class(TW3CustomConsoleApplication) // Versions 2.1 and 3.0 uses System.Types, System.Lists, SmartCL.System, SmartCL.Scroll, SmartCL.Console, SmartCL.Components, SmartCL.Application, SmartCL.ConsoleApp; type TApplication = class(TW3CustomConsoleApplication)
Visual Components Project
// Version 2.0 uses W3System, W3Components, W3Forms, W3Application, Form1; type TApplication = class(TW3CustomApplication) // Version 2.1 uses Pseudo.CreateForms, // auto-generated unit that creates forms during startup System.Types, SmartCL.System, SmartCL.Components, SmartCL.Forms, SmartCL.Application, Form1; type TApplication = class(TW3CustomApplication) // Version 3.0 uses Pseudo.CreateForms, // auto-generated unit that creates forms during startup System.Types, SmartCL.System, SmartCL.Components, SmartCL.Forms, SmartCL.Application; type TApplication = class(TW3CustomApplication) end;
Note also that the XML view of the form has changed. For example, the first tag is now <SMART> instead of <SFM>