Attachment | Size |
---|---|
![]() | 45.61 KB |
I have a question about how to create/use a 'header' file on the Apple IIGS using ORCA/C
This topic is related to how to create, implement and use a user-defined function in ORCA/C v2.2 on an Apple IIGS.
The above function works within a program using it as a function prototype:
‘int gotoxy(int x, int y);’
located at the beginning of the file above (before) the opening brace ‘{‘ of the ‘main()’ function.
It can be called within ‘main()’ in the usual way. For example, if you want to position the cursor at X 40 (column 40 of the 80 column screen) and Y at 10 (row 10), then it would be called as…
gotoxy(40,10);
The above definition would be placed after the closing brace ‘}’ of the ‘main()’ function.
This for use in a text environment, I believe a similarly named function already exists as part of the graphics library.
While I created a simple clear screen function a week ago as a test, I don’t remember the exact sequence of steps I followed such that it is able to be called as ‘clrscr()’ inside of a ‘main()’ function making it available via an include statement at the beginning of the source code file before the opening ‘main()’ function brace ‘{‘ as usual.
#include <clrscr>
Mike Westerfield’s ORCA C documentation does explain the process in the ‘Programming in Pieces’ heading beginning on page 28 of this documentation.
My issue is that it is unclear exactly what the steps are to create a header file because the process is written as prose instead of enumerated steps which, at least for me would be a helpful addition to clarify the process.
If anyone knows how to do this and can provide a step-by-step enumeration of the process steps, I would be appreciative.
Thank you for your time and any help you may be able to offer.
The answer is to:
Create a header file; save it with a .h extension
Compile the header file to disk (turn off link after compile)
Create an ‘implementation’ file; save with a .cc extension
Compile the implementation file to disk (turn off link after compile)
Create a ‘library’ file. In my case for the gotoxy file, I went to the ORCA text ‘shell’ environment and typed: ‘makelib gotoxylib +gotoxy.a’ . This created a gotoxylib file.
Place the ‘gotoxylib’ file at the beginning of the ORCA:Libraries folder. I did this using the ProSel-16 Sort directory tool.
Copy the ‘gotoxy.h’ file to ORCA:Libraries:ORCACDefs folder
Just to be safe, I rebooted to ensure that GS O/S would ‘see’ the files in their new locations.
I tested this by creating a file named ‘gotoxytst.cc’
#pragma keep “gotoxytst”
#include <gotoxy.h>
void main(void)
{
printf(“\f”); //clears the screen via a ‘formfeed’
gotoxy(12,40); //places the cursor at row12, col 40
printf(“**”); //prints 2 ‘**’ at the above screen location
gotoxy(21,0); //places the cursor at row 21, col 0)
}