March 29, 2024, 08:58:12 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


My First (working) Aurora Program

Started by Doc, November 04, 2005, 07:32:16 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Doc

Whew!
...my first attempt at coding in Aurora was a little too ambitious and pretty much a disaster.  :'(

(Doc thinking to himself ---> "Omigosh, I didn't know one person could generate so many compiler errors  and with such great consistency."  :-[  )

Plan B: Learn to walk before trying to run. Hummm... something a little more traditional

/*
Hello World Example
My first working Aurora Program
*/

global sub main()
{
string testString;

testString = "Hello World!";

writeln( testString + "\n\n" );

writeln( "Press Any Key\n" );
while GetKey() = "";
return 0;
}


It's not much, but it's a start.

-Doc-

Btw Paul,
How about a dedicated spot we can post other samples for folks to laugh at?

Ionic Wind Support Team

 ;D

Take small steps doc.  And please ask lots of questions.

I'll open up a 'source' forum sooner or later.

Paul.
Ionic Wind Support Team

Doc

Quote from: Ionic Wizard on November 04, 2005, 07:45:38 PM
;D

Take small steps doc.  And please ask lots of questions.

No doubt! ...this old boy will be crawling for awhile so just remember that it was you that suggested that I ask a lot of questions.  ;)  ;D  :o

I've copied your list of current commands and functions into a sourcefile and keep that open for reference, which as I look it over, does bring a question to mind:

CHR$(int num),HEAP; <---- What does the HEAP indicate here as well as in the other examples?

-Doc-

Ionic Wind Support Team

HEAP is allocated memory that is automatically managed by the compiler.  Used by the function libraries to return a string, or UDT in memory allocated with the AllocHeap function..

99.99% of the time you'll never have a need to use it directly like that.

Ionic Wind Support Team

Doc

Thanks for the info Paul.

Here's another really simple one...

/*
Aurora Sample: Calling Simple Functions and Subs
*/

global sub main()
{
writeln("Let's try out a couple of easy function calls \n" +
            "to help get used to calling subroutines in Aurora.. \n\n");

//---- Here are the sub calls ------
TimeAndDate();
showPath();

writeln("ba-dee, ba-dee, ba-dee... that's all folks!\n\n" +
" -Doc-   ;-) \n\n");
writeln( "Press Any Key To End\n" );

while GetKey() = "";
return 0;
}

//----- Display the time and date -----
SUB TimeAndDate()
{
string todayIs;
todayIs = "Today's date is: " + date$("dddd',' MMMM dd yyyy");
writeln( todayIs + "\n\n" );
writeln( "Press Any Key To Continue\n" );
while GetKey() = "";
cls();
return;
}

//----- Display the current path -----
SUB showPath()
{
string currentPath;
currentPath = GETSTARTPATH();
writeln("Now let's have a look at the current path, which is: \n\n");
        writeln(currentPath + "\n\n");
writeln( "Press Any Key To Continue\n" );
while GetKey() = "";
cls();
return;
}


I'm trying to attach a zip of the excutable so to show that it really does compile.  ;D

-Doc-

Ionic Wind Support Team

Ionic Wind Support Team

Doc

Here's another couple of Q's, Paul:
I've notice that you've included both openconsole() & closeconsole() to the language yet they aren't used in your examples, and mine seem to be working (such as they are) without them as well. Is there a "best practice" involved here or are these totally optional?

Also, am I correct in assuming that subs/functions do not have to be declared unless there are arguments to be passed to or from?

Thx,

-Doc-

Ionic Wind Support Team

openconsole is for a windows compile when you want to use the console funciton. 

You only need to delcare external and imported functions.  It doesn't hurt anything to declare all of them, just not needed.  The SUB statement specifies the return type.

sub mysub(int a),string
{
return str$(a);
}
Ionic Wind Support Team