SlideShare une entreprise Scribd logo
1  sur  33
Télécharger pour lire hors ligne
An Introduction to
Apple IIgs Programming
    in a High Level
       Language
              by
         Mike Stephens

       First Presented at
       Mt Keira Fest 2009
Topics To Cover
   What programming languages are available?
   An overview of Complete Pascal
   A quick introduction to Pascal
   Your very first program!
   Introducing the Toolbox
   Using the Toolbox
What programming languages are
           available?
BASIC Programming
   Applesoft BASIC with Toolbox extensions
    (Interpreted)
   TML BASIC
   Micol Advanced BASIC
   GSoft BASIC (Interpreted)
ORCA Languages
   ORCA/Integer BASIC
   ORCA/Pascal
   ORCA/C
   ORCA/Modula-2
Complete Pascal
My recommendation for anyone wanting to get
started with high level language programming on
the Apple IIgs is….

You guessed it!

Complete Pascal.
An overview of Complete Pascal
Complete Pascal
Positives:
 Is freely available

 Is a compiled language

 Has full access to the Apple IIgs Toolbox

 Has an uncomplicated and easy to learn
  development environment
 Has some nice extensions to Pascal
Complete Pascal

Negatives:
 Has some bugs in the GUI resource editor

 Produces larger & less efficient compiled code
  (as compared to ORCA/Pascal)
 Can not link to assembly code (however, inline
  assembly code is possible)
 No debugger
A quick introduction to Pascal
Pascal Overview (continued)
   In Complete Pascal, comments start with
    a (* and end with a *) OR comments may start
    with a { and end with a } .
   Examples of comments:
     (* this is a comment *)
     { so is this! }
Pascal Overview
The basic structure of a Pascal program is:
PROGRAM ProgramName (FileList);

CONST
     (* Constant declarations *)

TYPE
       (* Type declarations *)

VAR
       (* Variable declarations *)

       (* Subprogram definitions *)

BEGIN
     (* Executable statements *)
END.
Pascal Overview (continued)
   Rules for identifiers:
       Must begin with a letter from the English alphabet.
       Can be followed by alphanumeric characters (alphabetic
        characters and numerals) and possibly the underscore (_).
       May not contain certain special characters, many of which
        have special meanings in Pascal.
        ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] :
        " ; ' < > ? , . / |
       May be any of the reserved words (see the TML Pascal II
        manual for details).
Pascal Overview (continued)
   Pascal is not case sensitive!
       MyProgram, MYPROGRAM,
        and mYpRoGrAm are all equivalent.
   For readability purposes, it is a good idea to use
    meaningful capitalization.
   An identifier can be any length so long as it can
    fit on one line, however, in Complete Pascal
    only the first 255 characters are significant.
Pascal Array Types
   An array type defines a structure that has a set
    number of components, and all of the
    components are of the same type.
   Array types in Pascal take the form:
ARRAY[ <INDEX TYPE> ] OF <COMPONENT TYPE>


   For example, an array of 100 real numbers:
array[1..100] of real
Pascal Record Types
   A record type consists of a specified collection
    of components called fields, each one capable of
    being a different type. Each field of a record
    type must specify its type, and the name of its
    identifier. For example:
record
    year: integer;
    month: 1..12;
    day: 1..31;
end
Complete Pascal Strings
   A string type is a succession of characters having a dynamic
    length attribute and a constant dimension attribute of 1 to 255.
   The current value of the length attribute for a string type is
    returned by the standard function length.
   A null string is a string type value that has a dynamic length of
    zero.
   For example:
    var
    myString : string;
    myLength : Integer;

    myString := ‘Hello Mt Keira Fest!’;
    myLength := Length(myString); { myLength equals 20 }
Pascal Assignment
   Once you have declared a variable, you can store
    values in it. This is called assignment.
   To assign a value to a variable, follow this
    syntax:
    variable_name := expression;


   For example:
    myFloat := 10.559;
Pascal Relational Operators
   The operand types and the corresponding results for
    Relational operations are shown in the following table:

          Operator      Meaning
          <             Less than
          >             Greater than
          =             Equal to
          <=            Less than or equal to
          >=            Greater than or equal to
          <>            Not equal to
Complete Pascal Control Statements
   The GOTO statement will pass control to another part
    of the program located in the same block.
   The CYCLE statement forces a repetition statement to
    immediately execute the next iteration of a loop.
   The LEAVE statement forces the immediate exit from
    a repetition statement loop.
   The HALT statement will stop the execution of the
    program immediately.
Pascal Procedures
   A procedure declaration associates an identifier with a block of
    statements.
   A procedure is called by using the procedure identifier and the
    current parameters required by it.
   An example of a procedure declaration:
    procedure Num2String (N: integer; var S: string);
    var V: integer;
    begin
           V := Abs(N);
           S:='';
           repeat
               S:= concat(Chr(V mod 10 + ord('0')),S);
               V:= V div 10;
           until V = 0;
           if V<0 then S := Concat(('-',S);
    end;
Pascal Functions
   A function declaration associates an identifier with a block of statements, able
    to be called in order to calculate and return a value of the specified type.
   An example of a function declaration:

     function Num2String(N: integer;) : string;
     var V: integer;
     S: string;
     begin
          V := Abs(N):
          S := '';
          repeat
              S := concat(Chr(V mod 10 + ord('0')),S);
              V := V div 10;
          until V = 0;
          if V<0 then S := concat('-',S);
          Num2String := S;
     end;
Pascal Units
   Complete Pascal supports the use of Units,
    which are stand alone modules (or libraries)
    which may define any number of procedures
    and functions.
   Units are compiled separately.
   Units are made accessible to a main program or
    to other Units via the USES clause.
Your very first program!
Hello Mt Keira Fest!
   Open Complete Pascal and select FileNew
    from the menu.
   In the Create File box, type HelloKFest.p and
    click New.
   You will then be presented with a new window
    in which to type your first Complete Pascal
    program.
Hello Mt Keira Fest! (continued)
   Type in the following:
    Program HelloKFest;

    begin
      writeln(‘Hello (Mt) K(eira)Fest!!’);
      readln;
    end.
Compile Your Code
   You can check the syntax of your code without
    compiling it by clicking CompileCheck Syntax,
    however, most times you will probably just want
    to compile to disk by clicking CompileTo Disk.
   If everything went smoothly, you should have
    just created your first Complete Pascal textbook
    application!
Running Your Program
   You can execute your program by:
     Exiting Complete Pascal and running your program
      from the Finder; or
     From within Complete Pascal click GSOSTransfer
      and select your HELLOKFEST application and
      click Transfer.
Introducing the Toolbox
The Apple IIgs Toolbox
   The Apple IIgs Toolbox is comprised of a number of
    specialised tool sets.
   Each tool set is made up of a number of routines that
    you can use from within your own programs.
   The Toolbox routines are designed to hide the
    complexity of dealing with the IIgs hardware.
   To become really familiar with the Apple IIgs Toolbox,
    you need to have the 3 Toolbox reference manuals +
    the GS/OS manual.
What Do the Toolsets Provide?
   Quickdraw II - Graphics routines
   Memory Manager – allocating/deallocating
    memory
   Sound Toolset – load and play digitized sounds
   SANE – floating point routines
   Window Manager – create & handle windows
   Event Manager – handle system events
   Plus more!
Using the Toolbox
Complete Pascal & the Toolbox
   Complete Pascal comes complete with interface
    files necessary to hook directly into the Toolbox
    routines
   As a rule of thumb, each tool set is defined as a
    Unit, which you can use from your
    programs/units by adding the appropriate tool
    set interface file to the USES clause.

Contenu connexe

Tendances

ParaSail
ParaSail  ParaSail
ParaSail AdaCore
 
While loop
While loopWhile loop
While loopFeras_83
 
What is storage class
What is storage classWhat is storage class
What is storage classIsha Aggarwal
 
What is to loop in c++
What is to loop in c++What is to loop in c++
What is to loop in c++03446940736
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variablesSaurav Kumar
 
Working with Bytecode
Working with BytecodeWorking with Bytecode
Working with BytecodeMarcus Denker
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c languagetanmaymodi4
 
Notes: Verilog Part 4- Behavioural Modelling
Notes: Verilog Part 4- Behavioural ModellingNotes: Verilog Part 4- Behavioural Modelling
Notes: Verilog Part 4- Behavioural ModellingJay Baxi
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scalaStratio
 
Storage classes in c++
Storage classes in c++Storage classes in c++
Storage classes in c++Jaspal Singh
 
Types of storage class specifiers in c programming
Types of storage class specifiers in c programmingTypes of storage class specifiers in c programming
Types of storage class specifiers in c programmingAppili Vamsi Krishna
 
QVT Traceability: What does it really mean?
QVT Traceability: What does it really mean?QVT Traceability: What does it really mean?
QVT Traceability: What does it really mean?Edward Willink
 
Javascripts hidden treasures BY - https://geekyants.com/
Javascripts hidden treasures            BY  -  https://geekyants.com/Javascripts hidden treasures            BY  -  https://geekyants.com/
Javascripts hidden treasures BY - https://geekyants.com/Geekyants
 

Tendances (20)

ParaSail
ParaSail  ParaSail
ParaSail
 
While loop
While loopWhile loop
While loop
 
What is storage class
What is storage classWhat is storage class
What is storage class
 
What is to loop in c++
What is to loop in c++What is to loop in c++
What is to loop in c++
 
Closures
ClosuresClosures
Closures
 
Erlang
ErlangErlang
Erlang
 
The Loops
The LoopsThe Loops
The Loops
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
Learn Java Part 2
Learn Java Part 2Learn Java Part 2
Learn Java Part 2
 
Working with Bytecode
Working with BytecodeWorking with Bytecode
Working with Bytecode
 
Preprocessor directives in c language
Preprocessor directives in c languagePreprocessor directives in c language
Preprocessor directives in c language
 
Notes: Verilog Part 4- Behavioural Modelling
Notes: Verilog Part 4- Behavioural ModellingNotes: Verilog Part 4- Behavioural Modelling
Notes: Verilog Part 4- Behavioural Modelling
 
F#3.0
F#3.0 F#3.0
F#3.0
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
Loops c++
Loops c++Loops c++
Loops c++
 
Storage classes in c++
Storage classes in c++Storage classes in c++
Storage classes in c++
 
Types of storage class specifiers in c programming
Types of storage class specifiers in c programmingTypes of storage class specifiers in c programming
Types of storage class specifiers in c programming
 
QVT Traceability: What does it really mean?
QVT Traceability: What does it really mean?QVT Traceability: What does it really mean?
QVT Traceability: What does it really mean?
 
Javascripts hidden treasures BY - https://geekyants.com/
Javascripts hidden treasures            BY  -  https://geekyants.com/Javascripts hidden treasures            BY  -  https://geekyants.com/
Javascripts hidden treasures BY - https://geekyants.com/
 

Similaire à Apple IIgs Programming (K Fest)

Similaire à Apple IIgs Programming (K Fest) (20)

Intro to Scala
 Intro to Scala Intro to Scala
Intro to Scala
 
Evaluation and analysis of ALGOL, PASCAL and ADA
Evaluation and analysis of ALGOL, PASCAL and ADAEvaluation and analysis of ALGOL, PASCAL and ADA
Evaluation and analysis of ALGOL, PASCAL and ADA
 
Scala presentationjune112011
Scala presentationjune112011Scala presentationjune112011
Scala presentationjune112011
 
Swift, swiftly
Swift, swiftlySwift, swiftly
Swift, swiftly
 
Scala in a nutshell by venkat
Scala in a nutshell by venkatScala in a nutshell by venkat
Scala in a nutshell by venkat
 
Turbo pascal
Turbo pascalTurbo pascal
Turbo pascal
 
Introduction to scala for a c programmer
Introduction to scala for a c programmerIntroduction to scala for a c programmer
Introduction to scala for a c programmer
 
Scala tutorial
Scala tutorialScala tutorial
Scala tutorial
 
Scala tutorial
Scala tutorialScala tutorial
Scala tutorial
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Alp 05
Alp 05Alp 05
Alp 05
 
Alp 05
Alp 05Alp 05
Alp 05
 
Arduino Functions
Arduino FunctionsArduino Functions
Arduino Functions
 
Input-output
Input-outputInput-output
Input-output
 
CMSC 350 PROJECT 1
CMSC 350 PROJECT 1CMSC 350 PROJECT 1
CMSC 350 PROJECT 1
 
Pascal programming lecture notes
Pascal programming lecture notesPascal programming lecture notes
Pascal programming lecture notes
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
BACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docxBACKGROUND A shell provides a command-line interface for users. I.docx
BACKGROUND A shell provides a command-line interface for users. I.docx
 
[ASM]Lab6
[ASM]Lab6[ASM]Lab6
[ASM]Lab6
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Dernier (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Apple IIgs Programming (K Fest)

  • 1. An Introduction to Apple IIgs Programming in a High Level Language by Mike Stephens First Presented at Mt Keira Fest 2009
  • 2. Topics To Cover  What programming languages are available?  An overview of Complete Pascal  A quick introduction to Pascal  Your very first program!  Introducing the Toolbox  Using the Toolbox
  • 3. What programming languages are available?
  • 4. BASIC Programming  Applesoft BASIC with Toolbox extensions (Interpreted)  TML BASIC  Micol Advanced BASIC  GSoft BASIC (Interpreted)
  • 5. ORCA Languages  ORCA/Integer BASIC  ORCA/Pascal  ORCA/C  ORCA/Modula-2
  • 6. Complete Pascal My recommendation for anyone wanting to get started with high level language programming on the Apple IIgs is…. You guessed it! Complete Pascal.
  • 7. An overview of Complete Pascal
  • 8. Complete Pascal Positives:  Is freely available  Is a compiled language  Has full access to the Apple IIgs Toolbox  Has an uncomplicated and easy to learn development environment  Has some nice extensions to Pascal
  • 9. Complete Pascal Negatives:  Has some bugs in the GUI resource editor  Produces larger & less efficient compiled code (as compared to ORCA/Pascal)  Can not link to assembly code (however, inline assembly code is possible)  No debugger
  • 10. A quick introduction to Pascal
  • 11. Pascal Overview (continued)  In Complete Pascal, comments start with a (* and end with a *) OR comments may start with a { and end with a } .  Examples of comments:  (* this is a comment *)  { so is this! }
  • 12. Pascal Overview The basic structure of a Pascal program is: PROGRAM ProgramName (FileList); CONST (* Constant declarations *) TYPE (* Type declarations *) VAR (* Variable declarations *) (* Subprogram definitions *) BEGIN (* Executable statements *) END.
  • 13. Pascal Overview (continued)  Rules for identifiers:  Must begin with a letter from the English alphabet.  Can be followed by alphanumeric characters (alphabetic characters and numerals) and possibly the underscore (_).  May not contain certain special characters, many of which have special meanings in Pascal. ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / |  May be any of the reserved words (see the TML Pascal II manual for details).
  • 14. Pascal Overview (continued)  Pascal is not case sensitive!  MyProgram, MYPROGRAM, and mYpRoGrAm are all equivalent.  For readability purposes, it is a good idea to use meaningful capitalization.  An identifier can be any length so long as it can fit on one line, however, in Complete Pascal only the first 255 characters are significant.
  • 15. Pascal Array Types  An array type defines a structure that has a set number of components, and all of the components are of the same type.  Array types in Pascal take the form: ARRAY[ <INDEX TYPE> ] OF <COMPONENT TYPE>  For example, an array of 100 real numbers: array[1..100] of real
  • 16. Pascal Record Types  A record type consists of a specified collection of components called fields, each one capable of being a different type. Each field of a record type must specify its type, and the name of its identifier. For example: record year: integer; month: 1..12; day: 1..31; end
  • 17. Complete Pascal Strings  A string type is a succession of characters having a dynamic length attribute and a constant dimension attribute of 1 to 255.  The current value of the length attribute for a string type is returned by the standard function length.  A null string is a string type value that has a dynamic length of zero.  For example: var myString : string; myLength : Integer; myString := ‘Hello Mt Keira Fest!’; myLength := Length(myString); { myLength equals 20 }
  • 18. Pascal Assignment  Once you have declared a variable, you can store values in it. This is called assignment.  To assign a value to a variable, follow this syntax: variable_name := expression;  For example: myFloat := 10.559;
  • 19. Pascal Relational Operators  The operand types and the corresponding results for Relational operations are shown in the following table: Operator Meaning < Less than > Greater than = Equal to <= Less than or equal to >= Greater than or equal to <> Not equal to
  • 20. Complete Pascal Control Statements  The GOTO statement will pass control to another part of the program located in the same block.  The CYCLE statement forces a repetition statement to immediately execute the next iteration of a loop.  The LEAVE statement forces the immediate exit from a repetition statement loop.  The HALT statement will stop the execution of the program immediately.
  • 21. Pascal Procedures  A procedure declaration associates an identifier with a block of statements.  A procedure is called by using the procedure identifier and the current parameters required by it.  An example of a procedure declaration: procedure Num2String (N: integer; var S: string); var V: integer; begin V := Abs(N); S:=''; repeat S:= concat(Chr(V mod 10 + ord('0')),S); V:= V div 10; until V = 0; if V<0 then S := Concat(('-',S); end;
  • 22. Pascal Functions  A function declaration associates an identifier with a block of statements, able to be called in order to calculate and return a value of the specified type.  An example of a function declaration: function Num2String(N: integer;) : string; var V: integer; S: string; begin V := Abs(N): S := ''; repeat S := concat(Chr(V mod 10 + ord('0')),S); V := V div 10; until V = 0; if V<0 then S := concat('-',S); Num2String := S; end;
  • 23. Pascal Units  Complete Pascal supports the use of Units, which are stand alone modules (or libraries) which may define any number of procedures and functions.  Units are compiled separately.  Units are made accessible to a main program or to other Units via the USES clause.
  • 24. Your very first program!
  • 25. Hello Mt Keira Fest!  Open Complete Pascal and select FileNew from the menu.  In the Create File box, type HelloKFest.p and click New.  You will then be presented with a new window in which to type your first Complete Pascal program.
  • 26. Hello Mt Keira Fest! (continued)  Type in the following: Program HelloKFest; begin writeln(‘Hello (Mt) K(eira)Fest!!’); readln; end.
  • 27. Compile Your Code  You can check the syntax of your code without compiling it by clicking CompileCheck Syntax, however, most times you will probably just want to compile to disk by clicking CompileTo Disk.  If everything went smoothly, you should have just created your first Complete Pascal textbook application!
  • 28. Running Your Program  You can execute your program by:  Exiting Complete Pascal and running your program from the Finder; or  From within Complete Pascal click GSOSTransfer and select your HELLOKFEST application and click Transfer.
  • 30. The Apple IIgs Toolbox  The Apple IIgs Toolbox is comprised of a number of specialised tool sets.  Each tool set is made up of a number of routines that you can use from within your own programs.  The Toolbox routines are designed to hide the complexity of dealing with the IIgs hardware.  To become really familiar with the Apple IIgs Toolbox, you need to have the 3 Toolbox reference manuals + the GS/OS manual.
  • 31. What Do the Toolsets Provide?  Quickdraw II - Graphics routines  Memory Manager – allocating/deallocating memory  Sound Toolset – load and play digitized sounds  SANE – floating point routines  Window Manager – create & handle windows  Event Manager – handle system events  Plus more!
  • 33. Complete Pascal & the Toolbox  Complete Pascal comes complete with interface files necessary to hook directly into the Toolbox routines  As a rule of thumb, each tool set is defined as a Unit, which you can use from your programs/units by adding the appropriate tool set interface file to the USES clause.