Re: [BLACKBOX] Delphi-like parameters in Array Of Const

From: [at]} <Chris>
Date: Sun, 10 Oct 2010 09:54:26 +1030

----boundary-LibPST-iamunique-214662425_-_-
Content-type: text/plain

>-----Original Message-----
>From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>Sent: Saturday, 9 October 2010 11:48 PM
>To: BLACKBOX{([at]})nowhere.xy
>Subject: [BLACKBOX] Delphi-like parameters in Array Of Const
>
>There is very useful procedure in Delphi, called 'Format', for
>formatting string (and like 'sprintf' function in C). It
>receives a template string and open array of values with
>different types (e.g.
>integer, string and so on) and substitutes values in template.
>I'm looking for simple solution for formatting strings as
>above because not satisfied with Dialog.MapParamString.
>

I'm not aware of one. If you can't find something similar in BlackBox itself
you might find something in Helmut Zinn's Component Pascal Collection:

http://www.zinnamturm.eu

> > Internally, an array of const is an open array of TVarRec.

>How to implement such 'array of const' in Component Pascal? Is
>it possible?
>

An 'array of const' is a mechanism provided in Delphi to allow procedures to
have a variable number of parameters. This is not a feature which is
provided in Oberon / Component Pascal.

A (type safe) way to do this in CP is to have one parameter which is a
linked list of objects, each of which can be a different type. We use this
technique extensively (in Delphi, CP and GPCP software) to provide a generic
way of maintaining INI file / Windows registry values. It supports the use
of string, boolean and integer data types.

If you are only dealing with a few values then it is a simple problem
deserving a simple solution. Call a separate procedure for each value you
wish to format. If you have groups of similar calls then collect these into
one procedure with a fixed number of parameters. It might require a little
more typing but is likely to be more secure / reliable and be easier to
comprehend and maintain in the long term.

Regards,
Chris Burrows
CFB Software
Astrobe v3.2: ARM Oberon-07 Development System
http://www.astrobe.com


  


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-214662425_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcm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