Converter from Text to morse [help needed]

This is a discussion on Converter from Text to morse [help needed] within the Windows Programming forums, part of the Platform Specific Boards category; hi guys i have one problem,I want to make an application for windows that encodes a text into morse.... i ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Location
    Sérres, Greece, Greece
    Posts
    17

    Question Converter from Text to morse [help needed]

    hi guys i have one problem,I want to make an application for windows that encodes a text into morse....
    i use an EditBox to enter the the word,and then a Button to send a each letter to a StringGrid Cell.
    After that,through a loop I check the letter in every cell independently
    and turn it into a morse character (example where "a" put ".---")
    and the send it to a stringgrid_morse

    When i compile it, it doesn't give me any error.
    But when i run it,I get an error,and Dstring.h pops up
    in a line saying "ThrowIfOutOfRange(idx); // Should Range-checking be optional to avoid overhead ??"

    I need help I have been working on it 2 weeks (yeah I'm a noob xD)




    Unit1.cpp
    Code:
    //---------------------------------------------------------------------------
    
    #include <vcl.h>
    #pragma hdrstop
    
    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    
    
    void __fastcall TForm1::Encode_ButtonClick(TObject *Sender)
    {
    
    
    
       for(int i=0;i<=Edit_Text->Text.Length();i++)
            {
               StringGrid_Text->ColCount=Edit_Text->Text.Length();
               StringGrid_Text->Cells[i][0]=Edit_Text->Text[i];
    
               if(StringGrid_Text->Cells[i][0]=="a"|StringGrid_Text->Cells[i][0]=="A")
                {
                  StringGrid_Morse->Cells[i][0]=".-";
    
                 }
               else if (StringGrid_Text->Cells[i][0]=="b"|StringGrid_Text->Cells[i][0]=="B")
    
                     StringGrid_Morse->Cells[i][0]=".--";
    
    
    
            }
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::StringGrid_MorseClick(TObject *Sender)
    {
    
    }
    //---------------------------------------------------------------------------

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,339
    > StringGrid_Text->Cells[i][0]=Edit_Text->Text[i];
    Well you need to post your declaration of Cells, or otherwise convince us that it has been properly allocated with the correct size.

    > if(StringGrid_Text->Cells[i][0]=="a"|StringGrid_Text->Cells[i][0]=="A")
    Read up on the difference between | (bitwise) and || (logical)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Location
    Sérres, Greece, Greece
    Posts
    17
    > StringGrid_Text->Cells[i][0]=Edit_Text->Text[i];
    Well you need to post your declaration of Cells, or otherwise convince us that it has been properly allocated with the correct size.
    The "declaration" of cells is made in line above....

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,339
    Where?

    These are all 'use' of Cells, not a declaration.
    Code:
    //---------------------------------------------------------------------------
    
    #include <vcl.h>
    #pragma hdrstop
    
    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
            : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    
    
    void __fastcall TForm1::Encode_ButtonClick(TObject *Sender)
    {
    
    
    
       for(int i=0;i<=Edit_Text->Text.Length();i++)
            {
               StringGrid_Text->ColCount=Edit_Text->Text.Length();
               StringGrid_Text->Cells[i][0]=Edit_Text->Text[i];
    
               if(StringGrid_Text->Cells[i][0]=="a"|StringGrid_Text->Cells[i][0]=="A")
                {
                  StringGrid_Morse->Cells[i][0]=".-";
    
                 }
               else if (StringGrid_Text->Cells[i][0]=="b"|StringGrid_Text->Cells[i][0]=="B")
    
                     StringGrid_Morse->Cells[i][0]=".--";
    
    
    
            }
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::StringGrid_MorseClick(TObject *Sender)
    {
    
    }
    //---------------------------------------------------------------------------
    Post your header file, or wherever the struct/class is declared.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. beginner and need help to solve my morse code / text
    By tnkanubite in forum C++ Programming
    Replies: 1
    Last Post: 01-20-2012, 05:47 AM
  2. pdf to text converter
    By rehan in forum C++ Programming
    Replies: 2
    Last Post: 09-18-2007, 04:36 AM
  3. Replies: 14
    Last Post: 11-23-2005, 07:53 AM
  4. About the Morse code Converter
    By Amber_liam in forum C Programming
    Replies: 17
    Last Post: 05-29-2002, 08:35 AM
  5. funky little program - word to morse converter!
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-18-2002, 03:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21