O Componente TEdit do FMX, possui diversas propriedades,
e uma das mais importantes é a filtre char,
podemos fazer filtragem de qualquer caractere,
ou de dígitos, só passa o que queremos que passe,
por esta entrada de dados, mas deixando isto de lado,
resolvemos criar uma rotina de códigos para fazer
a separação de vogais e de consoantes de uma frase,
a parte lógica foi criada em C, mas pode ser convertido
para qualquer linguagem, não se assustem com os muitos códigos
da interface gráfica, boa sorte, bons estudos, e até o próximo post.
//---------------------------------------------------------------------------
#include <fmx.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.fmx"
#pragma resource ("*.Windows.fmx", _PLAT_MSWINDOWS)
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1 ( TComponent* Owner )
: TForm ( Owner )
{
}
int a, x;
//---------------------------------------------------------------------------
void __fastcall TForm1::Label_Manual ( TObject *Sender ) {
	Rectangle1 -> Width = 600;
	Rectangle1 -> Height = 300;
	Rectangle1 -> Position -> X = 0;
	Rectangle1 -> Position -> Y = 0;
	Label1 -> Position -> X = 170;
	Label1 -> Position -> Y = 210;
	Label1 -> Size -> Width = 200;
	Label1 -> Size -> Height = 30;
	Label1 -> TextSettings -> Font -> Size = 18;
	Label1 -> TextSettings -> FontColor = claBlack;
	Label1 -> TextSettings -> Font -> Family = "Consolas";
	Label1 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	Label1 -> Text = "Por: Samuel Lima";
	Label2 -> Position -> X = 170;
	Label2 -> Position -> Y = 225;
	Label2 -> Size -> Width = 200;
	Label2 -> Size -> Height = 30;
	Label2 -> TextSettings -> Font -> Size = 18;
	Label2 -> TextSettings -> FontColor = claBlack;
	Label2 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	Label2 -> Text = "sa_sp10@hotmail.com";
	Text1 -> Position -> X = -55;
	Text1 -> Position -> Y = 17;
	Text1 -> Size -> Width = 700;
	Text1 -> Size -> Height = 20;
	Text1 -> TextSettings -> Font -> Size = 16;
	Text1 -> TextSettings -> FontColor = claRed;
	//Text1 -> AutoSize = True;
	Text1 -> Size -> PlatformDefault = False;
	Text1 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	//Text1 -> Text = str_3;
	Text2 -> Position -> X = -145;
	Text2 -> Position -> Y = 47;
	Text2 -> Size -> Width = 700;
	Text2 -> Size -> Height = 20;
	Text2 -> TextSettings -> Font -> Size = 14;
	Text2 -> TextSettings -> FontColor = claBlack;
	//Text1 -> AutoSize = True;
	Text2 -> Size -> PlatformDefault = False;
	Text2 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	Text3 -> Position -> X = -186;
	Text3 -> Position -> Y = 67;
	Text3 -> Size -> Width = 700;
	Text3 -> Size -> Height = 20;
	Text3 -> TextSettings -> Font -> Size = 14;
	Text3 -> TextSettings -> FontColor = claRed;
	//Text1 -> AutoSize = True;
	Text3 -> Size -> PlatformDefault = False;
	Text3 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	Text4 -> Position -> X = -76;
	Text4 -> Position -> Y = 87;
	Text4 -> Size -> Width = 700;
	Text4 -> Size -> Height = 20;
	Text4 -> TextSettings -> Font -> Size = 14;
	Text4 -> TextSettings -> FontColor = claBlack;
	//Text4 -> AutoSize = True;
	Text4 -> Size -> PlatformDefault = False;
	Text4 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	//Text4 -> Text = "Por : ";
	Text5 -> Position -> X = -205;
	Text5 -> Position -> Y = 107;
	Text5 -> Size -> Width = 700;
	Text5 -> Size -> Height = 20;
	Text5 -> TextSettings -> Font -> Size = 14;
	Text5 -> TextSettings -> FontColor = claRed;
	//Text5 -> AutoSize = True;
	Text5 -> Size -> PlatformDefault = False;
	Text5 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	//Text5 -> Text = "Samuel lima";
	Text6 -> Position -> X = -95;
	Text6 -> Position -> Y = 127;
	Text6 -> Size -> Width = 700;
	Text6 -> Size -> Height = 20;
	Text6 -> TextSettings -> Font -> Size = 14;
	Text6 -> TextSettings -> FontColor = claBlack;
	//Text6 -> AutoSize = True;
	Text6 -> Size -> PlatformDefault = False;
	Text6 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	//Text6 -> Text = "sa_sp10@hotmail.com";
	Text7 -> Position -> X = -212;
	Text7 -> Position -> Y = 147;
	Text7 -> Size -> Width = 700;
	Text7 -> Size -> Height = 20;
	Text7 -> TextSettings -> Font -> Size = 14;
	Text7 -> TextSettings -> FontColor = claRed;
	//Text6 -> AutoSize = True;
	Text7 -> Size -> PlatformDefault = False;
	Text7 -> Font -> Style = TFontStyles ( ) << fsBold << fsItalic;
	//Text6 -> Text = "sa_sp10@hotmail.com";
	Edit1 -> SetFocus ( );
	Edit1 -> Font -> Size = 10;
	Edit1 -> Width = 130;
	Edit1 -> Height = 17;
	Edit1 -> Position -> X = 277;
	Edit1 -> Position -> Y = 47;
	Button1 -> Width = 30;
	Button1 -> Height = 17;
	Button1 -> Position -> X = 415;
	Button1 -> Position -> Y = 47;
	Button1 -> TextSettings -> Font -> Family = "Arial";
	//Button1 -> TextSettings -> Font -> Size = 16;
	Button1 -> TextSettings -> FontColor = claBlue;
	Button2 -> Width = 50;
	Button2 -> Height = 17;
	Button2 -> Position -> X = 470;
	Button2 -> Position -> Y = 260;
	Button2 -> TextSettings -> Font -> Family = "Arial";
	Button2 -> TextSettings -> Font -> Size = 16;
	Button2 -> TextSettings -> FontColor = claRed;
	Button2 -> Text = "Sair";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow ( TObject *Sender ) {
	Label_Manual ( Sender );
	Text1 -> Text = "FMX - SEPARANDO VOGAIS E CONSOANTES EM FRASES";
	a = 0;
	if ( a == 0 )
		Text2 -> Text = "Digite uma frase : ";
	Button1 -> Text = "Ok";
	Button2 -> Visible = false;
	Label1 -> Visible = false;
	Label2 -> Visible = false;
	Edit1 -> Visible = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click ( TObject *Sender ) {
	a++;
	int i, j, k, h = 0, lenv, lenv_1;
	char Vogais [ ] = { 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U' };
	lenv_1 = strlen ( Vogais );
	char str [ 50 ] = " ";
	char Vet [ 50 ];
	String st;
	st += Edit1 -> Text;
	wcstombs (  str, st.c_str ( ), 50 );
	lenv = strlen ( str );
	if ( a == 1 ) {
		Edit1 -> Visible = false;
		Text2 -> Text = "Abaixo a frase digitada: ";
		Button1 -> Width = 100;
		Button1 -> Height = 17;
		Button1 -> Position -> X = 130;
		Button1 -> Position -> Y = 260;
		Button1 -> TextSettings -> Font -> Family = "Arial";
		Button1 -> TextSettings -> Font -> Size = 16;
		Button1 -> TextSettings -> FontColor = claRed;
		Button1 -> Text = "Pressione";
		for ( i = 0; i < lenv; i++ ) {
			Text3 -> Text += str [ i ];
		}
	}
	if ( a == 2 ) {
		Text4 -> Text = "Imprimindo abaixo só as consoantes da frase";
		for ( i = 0; i < lenv; i++ ) {
			for ( j = 0; j < lenv; j++ )
				if ( str [ i ] == Vogais [ j ] )
					break;
			if ( j == lenv ) {
				Text5 -> Text += str [ i ];
			}
		}
	}
	if ( a == 3 ) {
		Text6 -> Text = "Imprimindo abaixo só as vogais da frase";
		for ( i = 0; i < lenv; i++ ) {
			for ( j = 0; j < lenv_1; j++ ) {
				if ( Vogais [ j ] == str [ i ] ) {
					Vet [ h ] = str [ i ];
					h++;
				}
			}
		}
		k = h;
		for ( h = 0; h < k; h++ ) {
			Text7 -> Text += Vet [ h ];
		}
		Button1 -> Text = "Nova frase";
		Button2 -> Visible = true;
		Label1 -> Visible = true;
		Label2 -> Visible = true;
	}
	if ( a == 4 ) {
		Text3 -> Text = " ";
		Text4 -> Text = " ";
		Text5 -> Text = " ";
		Text6 -> Text = " ";
		Text7 -> Text = " ";
		Edit1 -> Text = "";
		FormShow ( Sender );
	}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click ( TObject *Sender ) {
	Close ( );
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <System.Classes.hpp>
#include <FMX.Controls.hpp>
#include <FMX.Forms.hpp>
#include <FMX.Controls.Presentation.hpp>
#include <FMX.Objects.hpp>
#include <FMX.StdCtrls.hpp>
#include <FMX.Types.hpp>
#include <FMX.Edit.hpp>
#include <FMX.Graphics.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:	// IDE-managed Components
	TRectangle *Rectangle1;
	TLabel *Label1;
	TLabel *Label2;
	TEdit *Edit1;
	TButton *Button1;
	TButton *Button2;
	TText *Text1;
	TText *Text2;
	TText *Text3;
	TText *Text4;
	TText *Text5;
	TText *Text6;
	TText *Text7;
	void __fastcall FormShow ( TObject *Sender );
	void __fastcall Label_Manual ( TObject *Sender );
	void __fastcall Button1Click ( TObject *Sender );
	void __fastcall Button2Click ( TObject *Sender );
private:	// User declarations
public:		// User declarations
	__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
 
Nenhum comentário:
Postar um comentário
Observação: somente um membro deste blog pode postar um comentário.