Discussion:
BlackBox interactivity issues: 2
(too old to reply)
Xcriber51
2007-04-17 12:32:55 UTC
Permalink
Hi

I'm trying to learn Blackbox, and it is definitely an acquired taste.
(Though I'm hopeful when it's acquired, it'll taste good.)

Just a couple of simple things:

- I'm trying to utilize the command-oriented nature of the Oberon-like
environment. So, when I type

"StdLog.String('Hello, world!')"

in the log area, select it, and Dev>Execute it, it works fine and prints
the text in the log area. However, when I type

"Math.Sin(12)"

-or-

"StdLog.Real(Math.Sin(12))"

I start getting pointless errors. What am I doing wrong?

- I like the document-centric philosophy. However, I'm not able to fully
utilize it. Is it possible to link to a TeX package, place some TeX code
in a document with Oberon code sprinkled in between, and then compile the
sources (TeX for say a DVI file, Oberon for an executable)?

- What exactly does the Tools>Insert Clock thingie do? Does it have any
relation with the "timing" feature -- which seems to always print 0
whenever I try to time a code (which is probably true since Oberon looks
super-efficient, but you see, I want more detail. Instead of "0", a
"0:00:125" would be more informative).

Thanks


-- Ken
Chris Burrows
2007-04-17 13:13:15 UTC
Permalink
Post by Xcriber51
- What exactly does the Tools>Insert Clock thingie do?
It should insert, into the current open document, an animated picture of an
analog clock showing the current time, with the seconds hand moving.
Post by Xcriber51
Does it have any
relation with the "timing" feature -- which seems to always print 0
whenever I try to time a code (which is probably true since Oberon looks
super-efficient, but you see, I want more detail. Instead of "0", a
"0:00:125" would be more informative).
Which 'timing feature' are you referring to?

Services.Ticks() returns the current time with a resolution on Windows XP >
10ms. You are right, your code would have to do something substantial to
register an elapsed time with this sort of resolution on one of today's
typical multi-Ghz CPUs.

A first attempt at timing a function might go like this:

start := Services.Ticks();
DoSomething();
finish := Services.Ticks();
elapsedTime := finish - start;

A more refined example of this is TBoxTimer at Helmut Zinn's excellent
Component Pascal Collection site:

http://www.zinnamturm.de/Topics.htm#Timer

If you want to get timing down to microsecond resolution I have a couple of
routines that do this using the WinApi.QueryPerformanceCounter functions.

Also, on the subject of timing, Blackbox's DevProfiler is extremely useful
if you want to identify time-related bottlenecks in your code.

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp
Xcriber51
2007-04-18 09:27:58 UTC
Permalink
Thanks Chris.

How about the other issue -- errors raised when a function is called with
a command (e.g. as "Math.Sin(12)")?


-- Ken
Chris Burrows
2007-04-18 13:24:11 UTC
Permalink
Post by Xcriber51
How about the other issue -- errors raised when a function is called with
a command (e.g. as "Math.Sin(12)")?
Math.Sin is not one of the valid types of procedure that can be executed in
a command.

Look at the Blackbox StdInterpreter documentation (Std/Docu/Interpreter.odc)
to see a list of all the valid types of procedure calls that can be executed
by a command. Functions (i.e. procedures returning a value, like Math.Sin)
are not included.

One way of doing what you are trying to do is to use the same technique that
I suggested for the Oscillation example you asked about the other day. i.e.
Write a small program that wraps the functions, that you want to call, in an
exported procedure which is one of the allowable types. Then call that
exported procedure from a commander.

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp

Loading...