Now we create the actual client application.
library.dylan, and add to the define library declaration the following line:
use RotNExample-client-stubs;
define module declaration in module.dylan.
We now add code to make the client encrypt and decrypt a simple string with the default key of 13 and with the key set to 3.
Note: The remainder of this section of the example involves adding code to RotNExample-client.dylan. A version of this file with all the code we add in this section is available in the Functional Developer installation folder, under Examples\Documentation\RotNExample\RotNExample-client.dylan. You may want to copy that file into place in your project folder rather than typing code in.
main method in RotNExample-client.dylan to look like the following.
define method main () => ()
with-ole
format-out("Client connecting to server.\n");
let server = make-RotNExample();
local method encrypt-and-decrypt () => ()
let plaintext = "And he was going ooo-la, oooooo-la...";
format-out("Plaintext is %=, encrypting.\n", plaintext);
let ciphertext = IRotNExample/encrypt(server, plaintext);
format-out("Ciphertext is %=, decrypting.\n", ciphertext);
let decrypted = IRotNExample/decrypt(server, ciphertext);
format-out("Decrypted text is %=.\n", decrypted);
end method;
encrypt-and-decrypt();
server.IRotNExample/key := 3;
format-out("Set key to %d.\n", server.IRotNExample/key);
encrypt-and-decrypt();
format-out("Client releasing server.\n");
release(server);
end with-ole;
end method main;
The with-ole macro initializes OLE at entry and uninitializes it at exit.
RotNExample-client-stubs.hdp.