# Attempt to build the Ada Rosetta Code "Caesar cipher" Task fails

**URL:** <https://forum.ada-lang.io/t/attempt-to-build-the-ada-rosetta-code-caesar-cipher-task-fails/757>\
**Category:** General\
**Created:** [April 9, 2024, 7:40pm UTC](https://forum.ada-lang.io/t/attempt-to-build-the-ada-rosetta-code-caesar-cipher-task-fails/757 "2024-04-09T19:40:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ret\_Build\_Engineer](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/ccd318/32.png) [@Ret\_Build\_Engineer](https://forum.ada-lang.io/u/Ret_Build_Engineer)\
**Post date:** [April 9, 2024, 7:40pm UTC](https://forum.ada-lang.io/t/attempt-to-build-the-ada-rosetta-code-caesar-cipher-task-fails/757/1 "2024-04-09T19:40:37Z")

</div>

Hi;

I am unable to build the Ada Rosetta Code Caesar cipher Task.

[Caesar cipher - Rosetta Code](https://rosettacode.org/wiki/Caesar_cipher#Ada)

—+++++++++++++++++++++++++++++++++++++++++++++++++  
/opt/gcc-13.2.0-aarch64/bin/gnatmake  
gcc -c -I./ -I- ./caesar.adb  
caesar.adb:7:24: error: “modulo” is undefined  
caesar.adb:7:30: error: missing “;”  
caesar.adb:14:31: error: subprogram “modulo26” cannot be used before end of its declaration  
caesar.adb:16:39: error: prefix of “Pos” attribute must be a type  
caesar.adb:19:39: error: subprogram “modulo26” cannot be used before end of its declaration  
caesar.adb:24:35: error: subprogram “modulo26” cannot be used before end of its declaration  
caesar.adb:26:35: error: subprogram “modulo26” cannot be used before end of its declaration  
caesar.adb:35:08: error: subprogram “modulo26” cannot be used before end of its declaration  
gnatmake: “./caesar.adb” compilation error  
Build failed.  
—+++++++++++++++++++++++++++++++++++++++++++++++++

Is this a coding error in the Rosetta Code Task or is it that it worked in an earlier version of Ada or a different Ada compiler?

Thanks,  
Retired Build Engineer

---

<div class="post-metadata">

**Author:** ![mgrojo](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/mgrojo/32/15_2.png) [@mgrojo](https://forum.ada-lang.io/u/mgrojo)\
**Post date:** [April 9, 2024, 8:19pm UTC](https://forum.ada-lang.io/t/attempt-to-build-the-ada-rosetta-code-caesar-cipher-task-fails/757/2 "2024-04-09T20:19:53Z")

</div>

That’s a horror, not near to be valid Ada. It seems a joke or something machine-generated, but then, not very current. Bing copilot was able to generate this near valid implementation:

```ada
-- Caesar Cipher Implementation in Ada

with Ada.Text_IO;
use Ada.Text_IO;

procedure Caesar_Cipher is
   -- Function to encrypt a character
   function Encrypt_Char(Char_To_Encrypt: Character; Shift: Integer) return Character is
      begin
         if Char_To_Encrypt in 'A'..'Z' then
            -- Only encrypt uppercase letters
            return Character'Val((Character'Pos(Char_To_Encrypt) + Shift - Character'Pos('A')) mod 26 + Character'Pos('A'));
         else
            -- Leave other characters unchanged
            return Char_To_Encrypt;
         end if;
      end Encrypt_Char;

   -- Function to decrypt a character
   function Decrypt_Char(Char_To_Decrypt: Character; Shift: Integer) return Character is
      begin
         if Char_To_Decrypt in 'A'..'Z' then
            -- Only decrypt uppercase letters
            return Character'Val((Character'Pos(Char_To_Decrypt) - Shift - Character'Pos('A')) mod 26 + Character'Pos('A'));
         else
            -- Leave other characters unchanged
            return Char_To_Decrypt;
         end if;
      end Decrypt_Char;

   -- Main procedure
   procedure Main is
      Message: String := "HELLO, WORLD!"; -- Example message
      Shift: Integer := 3; -- Shift value (can be any positive integer)

      Encrypted_Message: String(1..Message'Length);
      Decrypted_Message: String(1..Message'Length);
   begin
      -- Encrypt the message
      for I in Message'Range loop
         Encrypted_Message(I) := Encrypt_Char(Message(I), Shift);
      end loop;

      -- Decrypt the encrypted message
      for I in Message'Range loop
         Decrypted_Message(I) := Decrypt_Char(Encrypted_Message(I), Shift);
      end loop;

      -- Display results
      Put_Line("Original Message: " & Message);
      Put_Line("Encrypted Message: " & Encrypted_Message);
      Put_Line("Decrypted Message: " & Decrypted_Message);
   end Main;
begin
   null; -- Empty body
end Caesar_Cipher;

```

I only had to change `null;` to `Main;` to make it work.

---

<div class="post-metadata">

**Author:** ![Ret\_Build\_Engineer](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/ccd318/32.png) [@Ret\_Build\_Engineer](https://forum.ada-lang.io/u/Ret_Build_Engineer)\
**Post date:** [April 9, 2024, 9:14pm UTC](https://forum.ada-lang.io/t/attempt-to-build-the-ada-rosetta-code-caesar-cipher-task-fails/757/3 "2024-04-09T21:14:14Z")

</div>

Thank you.

I just did not have any idea how to fix it without rewriting it from scratch.

I’m not planning on updating the Rosetta Code Task, as I did not contribute to the fix 🙂

What is “Bing copilot”? I’ll google it.

Thanks,  
Retired Build Engineer

---

<div class="post-metadata">

**Author:** ![Ret\_Build\_Engineer](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/ccd318/32.png) [@Ret\_Build\_Engineer](https://forum.ada-lang.io/u/Ret_Build_Engineer)\
**Post date:** [April 9, 2024, 9:15pm UTC](https://forum.ada-lang.io/t/attempt-to-build-the-ada-rosetta-code-caesar-cipher-task-fails/757/4 "2024-04-09T21:15:05Z")

</div>

Ah, like ChatGPT or Gemini (Google AI).

---

<div class="post-metadata">

**Author:** ![mgrojo](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/mgrojo/32/15_2.png) [@mgrojo](https://forum.ada-lang.io/u/mgrojo)\
**Post date:** [April 10, 2024, 9:11pm UTC](https://forum.ada-lang.io/t/attempt-to-build-the-ada-rosetta-code-caesar-cipher-task-fails/757/5 "2024-04-10T21:11:33Z")

</div>

I’ve created an account to fix that example.
