Alias and multiple names for attributes - eiffel

Defining various names for a same feature seems possible in Eiffel, what for the attributes?
Is it possible to name an attribute like:
background, bk: COLOR
foreground, fg: COLOR
If not why?

In Eiffel
background, bk: COLOR
is the same as
background: COLOR
bk: COLOR
(same convention for local variables, arguments, ...)
To have a kind of alias on an attribute, you may do
background: COLOR assign set_background
bk: COLOR assign set_background
do
Result := background
end
set_background (c: COLOR)
do
background := c
end
Side note: for function and procedure ... even if it looks an alias
foo, bar: STRING
do
Result := "abc"
end
In fact, bar is not an alias for foo, they are two different features.
In descendant, you can rename, redefine one or the other independently.
There is no notion of such alias name in Eiffel. The only concept of alias is used to have operator such as plus alias "+" (s: READABLE_STRING_GENERAL): like Current in class STRING_32 .
Or also in HASH_TABLE item alias "[]"

Related

Eiffel, multiple types conformance: a way to specify that a parameter is a descendent from A and B?

Is there a way (I'm sure there is out of runtime check...) to specify that a parameter or a variable in general conforms to multiple types? to avoid doing something such as
work (a_printer: PRINTER; a_scanner: SCANNER)
do
a_printer.print
a_scanner.scan
-- OR without second parameter
if attached {SCANNER} a_printer as l_scanner then
l_scanner.scan
else
throw RuntimeError
end
end
If feature work belongs to a class that may have formal generic parameters, it could be defined as taking one argument of the corresponding formal generic type:
class X [D -> {PRINTER, SCANNER}] feature
work (device: D)
do
device.scan
device.print
end
end
Then, at the caller site, one could make the call
x.work (multi_function_device)
where x has an appropriate type, e.g. X [MULTI_FUNCTION_PRINTER].
If work could also be declared and implemented as a class feature, the temporary variable could be avoided:
{X [like multi_function_device]}.work (multi_function_device)
If the auxiliary class X is not an option, the current version of the language provides no means to declare an argument as conforming to more than 1 type (e.g., work (d: {PRINTER, SCANNER})), so you would have to resort to preconditions like
work (p: PRINTER)
require
attached {SCANNER} p
do
check
from_precondition: attached {SCANNER} p as s
then
s.scan
end
p.print
end
I think that, if possible, you should use a common ancestor to your multiple types. If you cannot (if you are using library types), you can create descendant classes (MY_PRINTER inherit from PRINTER and DEVICE and MY_SCANNER inherit from SCANNER and DEVICE). Another way is to use ANY as the type, but it is not the best solution.

Eiffel: setting a constant with reference to other class constant

How to set a constant refering to another class constant in Eiffel?
Something like that doesn't compile unfortunately
Default_log_level: like {MY_LOGGER}.log_level = {MY_LOGGER}.Log_level_info
Constant attributes cannot be defined using other constant attributes in the current version of Eiffel.
Constant attributes can only be made of a manifest constant, but a possible workaround could be to use frozen once functions:
frozen Default_log_level: INTEGER
once
Result := {MY_LOGGER}.Log_level_info
ensure
definition: Result = {MY_LOGGER}.Log_level_info
end
frozen means that it cannot be redefined in descendant classes (like constant attributes).
Unfortunately, the type of once functions cannot rely on anchored types, hence the use of INTEGER instead of like {MY_LOGGER}.log_level.
And finally, the drawback with this solution is that it cannot be used where constant attributes are expected (e.g. in inspect instructions).

Is there any way to change the text size (font size) of specific blocks when you using asciidoc?

I need your help.
Now I am using AsciiDoc and AsciiDoctor to create some manuals.
I want texts smaller on some specific blocks, for example wide table, wide list, and so on, but not want main texts smaller.
Especially I need to make texts of wide tables smaller as my customer requests so.
Is there any way?
You mention lists and tables...
About lists, it can't be done as stated in AsciiDoctor Documentation:
Unsupported
Complex AsciiDoc markup is not permitted in attribute values, such as:
lists
multiple paragraphs
other whitespace-dependent markup types
As you can see, there it mentions multiple paragraphs, so while #EhmKah answer is a correct way to set a custom styling block, it won't be rendered as expected in a table/list as it's multi-paragraph.
The Built-in CSS class syntax is the way to go [small]#any phrases#
But in order to make this work in a table, you must set the cell type with a specifier in this case, the AsciiDoc specifier denoted by a
This means the cell (or column) will render supported AsciiDoc statements, attributes, etc.
Here's a working example:
[frame="none",grid="none"]
|====
a| image::images\logo.png[] a|[.small]#Autor: {author}#
|====
If you have tons of rows/columns, you don't have to manually apply the a to all of them. You can set the columns you need this behavior this way:
[cols="1a,2a",frame="none",grid="none"]
|====
| image::images\logo.png[] |[.small]#Autor: {author}#
|====
You can check its documentation for more about Column Formatting and you can check the Rendered table with variable widths and alignments sub section for more about AsciiDoc (a) and other specifiers.
docinfo.html + --attribute docinfo=shared
You can drop your CSS modifications into a file called docinfo.html:
<style>
/* Your custom CSS. */
</style>
and then build with:
asciidoctor --attribute docinfo=shared README.adoc
and that makes Asciidoctor 2.0.10 place docinfo.html at the bottom of the <head> element.
So you can override most of the default Asciidoctor style from there.
Then it's just a matter of understanding the generated HTML and previous style definitions to override them.
For image specifically, see also: How to set a custom image height for an image in Asciidoctor?
When you use a theme file, you can add a role to it like this:
role:
mycustomfont:
font-color: #333
font-size: 10
Now you can reference your newly created role right from your table cell:
a|[.mycustomfont]# some text #
I read something about
[small] and [%autofit] option https://github.com/asciidoctor/asciidoctor-pdf/issues/185 I never needed it so maybe you give it a try.
example-code
[small]
----
should be rendered in smaller font.
----
[%autofit]
----
really long text that doesn't want to fit on a single line with the default font size, so we'll make it shrink to fit.
----

How can I declare and set the value from a radiobutton object with TSQL syntax?

I have a webform with a textfield.
The webform is connected to an integral database. But for this I don't need to store the value from this radiobutton into a table. I just want to take that value, and use it as a return for another field, just like it was not connected to a database at all.
In my TSQL code I assigned this textfield to a variable like this:
DECLARE #vak1 int
SET #vak1 = '[field name='vak1']'.
'field name' is the name of the object of that textfield. And I named it vak1.
I also want to put the checkedvalue from a radiobutton control into a variable, just like I did in the example above. But I dont know the name of the object, like in the above example it is field name for a textfield. So I need to know the standard name of a radiobutton object. These are all being used as LOCAL variables.
For example:
DECLARE #radio int
SET #radio = '[ x = 'No_cure_no_pay']'
The name No_cure_no_pay is the name of the radiobutton object. But what should I call x here? In the upper example it is 'field name' for a text field webcontrol.
What is the name for a radio button webcontrol?
The software I am using is custom made 3rd party software by a local Dutch company and it is not well known. So I cannot provide much info on the internals of the database. I don't have much code. Just these two lines would suffice, because the rest is pretty much the same just with different variable names. I will just use the values as return values. Just need to know how to declare and set a checked radiobutton value.

Store radiobutton checkedvalue in variable with TSQL

I have a webform with a textfield.
The webform is connected to an integral database. But for this I don't need to store the value from this radiobutton into a table. I just want to take that value, and use it as a return for another field, just like it was not connected to a database at all.
In my TSQL code I assigned this textfield to a variable like this:
DECLARE #vak1 int
SET #vak1 = '[field name='vak1']'.
'field name' is the name of the object of that textfield. And I named it vak1.
I also want to put the checkedvalue from a radiobutton control into a variable, just like I did in the example above. But I dont know the name of the object, like in the above example it is field name for a textfield. So I need to know the standard name of a radiobutton object. These are all being used as LOCAL variables.
For example:
DECLARE #radio int
SET #radio = '[ x = 'No_cure_no_pay']'
The name No_cure_no_pay is the name of the radiobutton object. But what should I call x here? In the upper example it is 'field name' for a text field webcontrol.
What is the name for a radio button webcontrol?
The software I am using is custom made 3rd party software by a local Dutch company and it is not well known. So I cannot provide much info on the internals of the database. I don't have much code. Just these two lines would suffice, because the rest is pretty much the same just with different variable names. I will just use the values as return values. Just need to know how to declare and set a checked radiobutton value.

Resources