Oberon Community Platform Forum
December 07, 2019, 07:58:05 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Need help with this code  (Read 9533 times)
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« on: July 31, 2010, 08:52:41 PM »

Hello list:

Need help with this code, please:

Code:
MODULE QtrMile;
IMPORT Out IN Oberon;
VAR mi,qmi,cm,inch,ft,yd,m:REAL;
BEGIN
cm:=1.0;
m:=100*cm;
inch:=2.54*cm;
ft:=12*inch;
yd:=3*ft;
mi:=5280*ft;
qmi:=mi/4.0;

Out.String('A quarter mile is equal to:');Out.Ln;
Out.LongRealFix(qmi/m,20,6);Out.String(' meters');Out.Ln;
Out.LongRealFix(qmi/yd,20,6);Out.String(' yards');Out.Ln;
END QtrMile.

SystemTools.Free QtrMile~

QtrMile~

The above is code that I ported from oo2c. It compiles cleanly in A2, but when I execute it ( by clicking with my MouseWheel

 on the previous line) I get:


Quote
WMTextView: Command parsing error, res: 3903 (Expected ModuleName "." [ProcedureName])

Do I absolutely need to use at least one procedure in an Oberon module? I have yet to read that anywhere Wink

As well, all critique of coding style, etc, etc would be welcome and appreciated!

Logged

duke
Bernhard T.
Administrator
Full Member
*****
Posts: 164


« Reply #1 on: July 31, 2010, 10:36:57 PM »

Try:

Code:
MODULE QtrMile;
IMPORT Out IN Oberon;
VAR mi,qmi,cm,inch,ft,yd,m:REAL;

PROCEDURE Do*;
BEGIN END Do;

BEGIN
cm:=1.0; m:=100*cm;
inch:=2.54*cm; ft:=12*inch;
yd:=3*ft; mi:=5280*ft;
qmi:=mi/4.0;

Out.String('A quarter mile is equal to:');Out.Ln;
Out.LongRealFix(qmi/m,20,6);Out.String(' meters');Out.Ln;
Out.LongRealFix(qmi/yd,20,6);Out.String(' yards');Out.Ln;
END QtrMile.

You can click on QtrMile.Do ~

AFAIK, the "command interpreter" wants a command, ie.: SomeModule.SomeProcedure ...

The concept of commands is unknown to OOC.

PS: In this way it will work only once until you unload.

Bernhard
Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #2 on: July 31, 2010, 11:42:45 PM »

I see!

So the moral of the story is that in "true" Oberon,  Grin ,  a procedure - even an empty one - must be used in the "command". Am I correct?

What about my coding style? Is it OK?

Logged

duke
soren renner
Global Moderator
Full Member
*****
Posts: 216



« Reply #3 on: August 01, 2010, 04:56:26 PM »

Looks all right to me.
Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #4 on: August 01, 2010, 07:25:01 PM »

Cool! TTYL...
Logged

duke
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #5 on: August 02, 2010, 08:59:00 AM »

To load a module without executing a command offered by the module, either...


... middle click on ModuleName + "."  (dot is required, module will be loaded but an error message about the command not being found appears)

or

... SystemTools.Load ModuleName ~
Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #6 on: August 02, 2010, 02:21:17 PM »

To load a module without executing a command offered by the module, either...


... middle click on ModuleName + "."  (dot is required, module will be loaded but an error message about the command not being found appears)

or

... SystemTools.Load ModuleName ~

So this will load _and_ execute the "body" of a MODULE without actually calling a particular procedure within that same MODULE?
Logged

duke
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #7 on: August 02, 2010, 02:38:33 PM »

Quote
So this will load _and_ execute the "body" of a MODULE without actually calling a particular procedure within that same MODULE?
Yes.
Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #8 on: August 02, 2010, 05:05:48 PM »

Quote
So this will load _and_ execute the "body" of a MODULE without actually calling a particular procedure within that same MODULE?
Yes.

Excellent! Thank you...
Logged

duke
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #9 on: August 05, 2010, 03:06:39 PM »

Quote
So this will load _and_ execute the "body" of a MODULE without actually calling a particular procedure within that same MODULE?
Yes.

Update:  It doesn't seem to work....

So, according to what you said on another thread, PACO is suppose to be a superset of OP2, correct?

Here's the code:
Code:
MODULE QtrMile;
         IMPORT Out IN Oberon;
         VAR mi,qmi,cm,inch,ft,yd,m:REAL;
BEGIN
         cm:=1.0;
         m:=100*cm;
         inch:=2.54*cm;
         ft:=12*inch;
         yd:=3*ft;
         mi:=5280*ft;
         qmi:=mi/4.0;

         Out.String('A quarter mile is equal to:');Out.Ln;
         Out.LongRealFix(qmi/m,20,6);Out.String(' meters');Out.Ln;
         Out.LongRealFix(qmi/yd,20,6);Out.String(' yards');Out.Ln;
END QtrMile.

SystemTools.Free QtrMile ~

QtrMile. ~

When I middle-click on  QtrMile. ~
PET hangs. The Log Viewer shows the pid etc for the process, and nothing else. I then have to go to Inspect/Objects to kill the appropriate pid. When I do that, Trap emerges with a lot of feedback about "Oberon" something or other.

Try it out! AFAIK, the code is just simple Oberon-2 stuff.

Now if OP2 in Native Oberon on A2 was not broken, then I could fire up Tools/Oberon and go play there Wink
Logged

duke
masta
Newbie
*
Posts: 19


empamedia.ethz.ch


« Reply #10 on: August 06, 2010, 06:54:28 AM »

Habe das mal gestrippt auf
Out.Ln;

Dass PET haengt (auf UnixAos) kann ich reproduzieren.
Wenn allerdings eine Procedure do eingebaut wird, dann mit QtrMile.do ~ Modul geladen, so trapt es in und im log erscheint die Meldung
Quote
Oberon has been called from an outside process. Don't do that.
Das ist as simple as possible. Don't make it simpler.

Wie staubers schon gesagt hat: Oberon ist Sprache und Laufzeitumgebung. Ausserhalb von Oberon als Laufzeitumgebung ist eine der zwei Modulvariablen von Oberon.Out nicht initialisiert. Wenn Out.Ln nicht aufgerufen wird, so läuft QtrMile.do ~.

Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #11 on: August 06, 2010, 08:24:18 AM »

Quote
Try it out! AFAIK, the code is just simple Oberon-2 stuff.
This isn't Oberon-2 stuff, it's Native Oberon stuff. The module Out is written in the programming language Oberon-2 but it is supposed to run with the Native Oberon operating system (the module Out uses Native Oberon API's)!
That's what I meant: You can write Oberon-2 programs using PACO, but you cannot use Native Oberon API's in A2. You can, however, run your program compiled with PACO under Oberon (under A2).
« Last Edit: August 06, 2010, 08:26:24 AM by staubesv » Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #12 on: August 06, 2010, 03:21:19 PM »

Quote
Try it out! AFAIK, the code is just simple Oberon-2 stuff.
This isn't Oberon-2 stuff, it's Native Oberon stuff. The module Out is written in the programming language Oberon-2 but it is supposed to run with the Native Oberon operating system (the module Out uses Native Oberon API's)!
That's what I meant: You can write Oberon-2 programs using PACO, but you cannot use Native Oberon API's in A2. You can, however, run your program compiled with PACO under Oberon (under A2).

So the compiler available in Tools/Oberon - Native Oberon on A2 - is called PACO? I thought that it was OP2, and that it was broken on A2?
Logged

duke
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #13 on: August 06, 2010, 03:38:10 PM »

PACO is itself an A2 application but it can also be used to compile "Oberon" programs that later run under "A2 Oberon" (Oberon system running as application on A2).
OP2 is a Oberon application. Originally, it could also compile A2 programs that later run under A2, but some time ago, it was not maintained anymore. Now, Oberon programs compiled with OP2 (under "A2 Oberon") will run neither on A2 nor "A2 Oberon" because the object file generated by OP2 is not compatible to the A2 loader anymore (which also loads object files used by "A2 Oberon").

Native Oberon: The OP2 compiler that comes with Native Oberon is not affected by this issue and works as expected.
Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #14 on: August 06, 2010, 03:58:19 PM »

Thanks for clearing that up!
Logged

duke
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!