Entry
TSE: Clipboard: Copy: TSE: Windows: How to possibly handle similar copy to TSE or Windows clipboard?
Apr 17th, 2005 09:33
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 17 April 2005 - 09:16 pm ----------------------
TSE: Clipboard: Copy: TSE: Windows: How to possibly handle similar
copy to TSE or Windows clipboard?
---
Copying to the Windows clipboard and copying to the TSE editor
clipboard or both.
are very similar operations.
---
This are thus some variations of the same methodology (that is from
some entity copying to some other entity).
---
You could in generally solve this using a mirror symmetric
(transitive (=to go from A to C you go first from A to B,
and then from B to C) pair of functions:
---
e.g.
CopyFromTseClipboardToWindowsClipboard()
and
CopyFromWindowsClipboardToTseClipboard()
---
Then you only have to write it for one type (e.g. Copy to TSE
clipboard, and then call the Copy from TSE to Windows clipboard to
handle the copying to the Windows clipboard.
---
Thus:
[copy to Windows clipboard] =
[copy to TSE clipboard] +
[copy from TSE clipboard to Windows clipboard]
---
[copy to TSE clipboard] =
[copy to Windows clipboard] +
[copy from Windows clipboard to TSE clipboard]
---
---
This principle is extensible to other related operations.
In general using such transitive functions will lead for you having to
create a total amount of such functions proportional to N,
instead of proportional to N^2.
---
From | To
---------
a a
b b
c c
d d
e e
... ...
needs the functions ab, ac, ad, ae, ba, bc, bd, be, ..., ea, eb, ec,
ed, ...
Thus in general N . (N - 1) functions,
(because you combine every N possibilities with all other N
possibilities.
Thus
N . N
But here except with itself.
So
N . (N - 1)
thus)
or worked out (N^2 - N) functions totally.
---
---
Using the transitive approach:
Let
W = copy to Windows clipboard
T = copy to TSE clipboard
S = copy to string
F = copy to file
---
You choose any of the 4 above as the 'middle man'
in your conversions.
(thus in general, there are 4, or thus in general N, of such
equivalent systems below possible, depending on which element you
choose as the intermediary, the 'middle man').
In this case choose T, the TSE clipboard.
---
TW = copy from TSE clipboard to Windows clipboard
TS = copy from TSE clipboard to string
TF = copy from TSE clipboard to file
---
WT = copy from Windows clipboard to TSE clipboard
ST = copy from string to TSE clipboard
FT = copy from file to TSE clipboard
---
---
If you look at the above structure,
you will need thus totally
(N - 1)
+
(N - 1)
= 2 . (N - 1) of that transitive functions.
Because you combine a given element
with all other N elements, except itself.
That gives N - 1 possibilties.
And you do it the other way around,
by swapping that same elements.
That gives again N - 1 possibilities.
---
---
By combining them, you can then write the following transitive
relations for copying
W (To copy from Windows clipboard to Windows
clipboard: do nothing)
T = W + WT (To copy from Windows clipboard to TSE clipboard:
thus first copy to Windows clipboard, then from Windows clipboard to
TSE clipboard)
S = W + WT + TS (To copy from Windows clipboard to string: thus
first copy to Windows clipboard, then from Windows clipboard to TSE
clipboard, then from TSE clipboard to string)
F = W + WT + TF (To copy from Windows clipboard to file: thus first
copy to Windows clipboard, then from Windows clipboard to TSE
clipboard, then from TSE clipboard to file)
---
W = T + TW (To copy from TSE clipboard to Windows clipboard:
thus first copy to TSE clipboard, then from TSE clipboard to Windows
clipboard)
T (To copy from TSE clipboard to TSE clipboard: do
nothing)
S = T + TS (To copy from TSE clipboard to string: thus first
copy to TSE clipboard, then from TSE clipboard to string)
F = T + TF (To copy from TSE clipboard to file: thus first copy
to TSE clipboard, then from TSE clipboard to File)
---
W = S + ST + TW (To copy from string to Windows clipboard: thus
first copy to string, then from string to TSE clipboard, then from TSE
clipboard to Windows clipboard)
T = S + ST (To copy from string to TSE clipboard: thus first
copy to string, then from string to TSE clipboard)
S (To copy from string to string: do nothing)
F = S + ST + TF (To copy from string to file: thus first copy to
string, then from string to TSE clipboard, then from TSE clipboard to
file)
---
W = F + FT + TW (To copy from file to Windows clipboard: thus first
copy to file, then from file to TSE clipboard, then from TSE clipboard
to Windows clipboard)
T = F + FT (To copy from file to TSE clipboard: thus first copy
to file, then from file to TSE clipboard)
S = F + FT + TS (To copy from file to string: thus first copy to
file, then from file to TSE clipboard, then from TSE clipboard to
string)
F (To copy from file to file: do nothing)
---
---
Note: The conversion between elements not involving the 'middle man'
T, need the most conversions
(in this case 3 conversions).
Thus e.g. from
F to S
needs 3 steps
(=F + FT + TS,
as the given elements do not explicitely include the 'middle
man' T).
---
---
There are thus N . (N - 1), here thus 4 . 3 = 12 of this relations
above, which you can
solve with totally 2 . (N - 1), here thus 2 . 3 = 6 of this transitive
functions.
(=WT, , ,
TW, TS, TF,
, ST, ,
, FT, )
(that is only the combinations where T is present, you have
to create, all the others you can discard).
---
If you should have done it with brute force, you should have needed
to create
N . (N - 1) =
4 . 3 =
= 12
independent conversion functions
(=WT, WS, WF,
TW, TS, TF,
SW, ST, SF,
FW, FT, FS)
---
But using the 'middle man' approach you will only need
N . (N - 1)
-----------
2 . (N - 1)
= N / 2
or thus (N / 2), or here thus 4 / 2 or thus 2 times less conversions
functions to create.
---
---
Note:
Similar systems: natural language
---
To see the analogy, compare this system with the translation of
between e.g. 2 natural languages.
Then let Esperanto play the role of middle man.
To translate from e.g. English to Russian, you first translate from
English to Esperanto,
then from Esperanto to Russian.
---
If you want to cross translate between 4 natural languages, e.g.
English, German, Italian, Spanish you need only
2 . (N - 1), or here 2 . (4 - 1) = 2 . 3 = 6 translators.
Choosing e.g. 'Spanish' as the 'middle man', you need the following
translators:
1. English -> Spanish
2. German -> Spanish
3. Italian -> Spanish
4. Spanish -> English
5. Spanish -> German
6. Spanish -> Italian
To convert from e.g. English to Italian, you first translate fro
English to Spanish, then from Spanish to Italian.
---
If you should use brute force, you should instead need to hire 12
translators:
1. English -> German
2. English -> Italian
3. English -> Spanish
4. German -> English
5. German -> Italian
6. German -> Spanish
7. Italian -> English
8. Italian -> German
9. Italian -> Spanish
10. Spanish -> English
11. Spanish -> German
12. Spanish -> Italian
---
---
Note:
Similar systems: computer language
---
To see the analogy, compare this system with the translation of
between e.g. 2 computer languages.
Then let TSE play the role of middle man.
To translate from e.g. C++ to C#, you first translate from C++ to TSE,
then from TSE to C#.
---
If you want to cross translate between 4 computer languages, e.g. C++,
C#, Delphi, TSE you need only
2 . (N - 1), or here 2 . (4 - 1) = 2 . 3 = 6 translators.
Choosing e.g. 'TSE' as the 'middle man', you need the following
translators:
1. C++ -> TSE
2. C# -> TSE
3. Delphi -> TSE
4. TSE -> C++
5. TSE -> C#
6. TSE -> Delphi
To convert from e.g. C++ to Delphi, you first translate fro
C++ to TSE, then from TSE to Delphi.
---
If you should use brute force, you should instead need to create 12
translators:
1. C++ -> C#
2. C++ -> Delphi
3. C++ -> TSE
4. C# -> C++
5. C# -> Delphi
6. C# -> TSE
7. Delphi -> C++
8. Delphi -> C#
9. Delphi -> TSE
10. TSE -> C++
11. TSE -> C#
12. TSE -> Delphi
---
---
Note:
This systems behave like a so called 'group'.
---
---
Internet: see also:
---
----------------------------------------------------------------------