Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi and Text input (https://www.delphipraxis.net/182563-delphi-text-input.html)

drama22 31. Okt 2014 21:53

Delphi and Text input
 
hi, regarding my previews post iam trying to submit youtube links to other form i done with every thing but one thing has left ,, i want to allow only youtube links to be sent like only youtube links can be submitted i try method to force the text input to have more than 33 chars like this

Delphi-Quellcode:
begin
  if Length(Trim(Textinput.Text)) < 33 then
  begin
Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end
basically this well force to insert text longer than 33 length but thats not the goal ,, is there any function to check if there is youtube url or not ?

Sir Rufo 31. Okt 2014 22:03

AW: Delphi and Text input
 
Maybe if the text starts with

drama22 31. Okt 2014 22:07

AW: Delphi and Text input
 
Zitat:

Zitat von Sir Rufo (Beitrag 1278296)
Maybe if the text starts with

i think about that but iam stuck with coding i try somthing like that

Delphi-Quellcode:
if Length(Trim(textinput.Text)) < 33 then
  begin
Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end else
  if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end
but i got Thats not youtube link all the way cant send

Sir Rufo 31. Okt 2014 22:23

AW: Delphi and Text input
 
  1. check if the string starts with
    Delphi-Quellcode:
    http://
    and remove it (temporary variable)
  2. get all characters from the temporary variable until the first
    Delphi-Quellcode:
    /
    and check if that is equal to
    Delphi-Quellcode:
    youtube.com
    or ends with
    Delphi-Quellcode:
    .youtube.com

Sir Rufo 31. Okt 2014 22:30

AW: Delphi and Text input
 
Zitat:

Zitat von drama22 (Beitrag 1278297)
Delphi-Quellcode:
if Length(Trim(textinput.Text)) < 33 then
  begin
Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end else
  if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end
but i got Thats not youtube link all the way cant send

Well if the string starts with
Delphi-Quellcode:
http://youtube.com
, why do you show the message? Show the message if it NOT starts with. Simple logic

drama22 31. Okt 2014 22:41

AW: Delphi and Text input
 
Zitat:

Zitat von Sir Rufo (Beitrag 1278300)
Zitat:

Zitat von drama22 (Beitrag 1278297)
Delphi-Quellcode:
if Length(Trim(textinput.Text)) < 33 then
  begin
Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end else
  if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end
but i got Thats not youtube link all the way cant send

Well if the string starts with
Delphi-Quellcode:
http://youtube.com
, why do you show the message? Show the message if it NOT starts with. Simple logic


here is full code

Delphi-Quellcode:
procedure mainform.buttonclick(Sender: TObject);
begin
  if Length(Trim(textinput.Text)) < 33 then
  begin
Application.MessageBox('invalid Youtube link', 'Info!', mb_iconWarning);
  end else
  if not AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end else
  begin
MessageDlg('done', mtInformation, [mbOK],0);
close;
  end;
end;
but always get Thats not youtube link :(

Sir Rufo 31. Okt 2014 22:47

AW: Delphi and Text input
 
Sorry to hear that but I think your delphi is broken.

if this
Delphi-Quellcode:
if not AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end;
and that
Delphi-Quellcode:
if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end;
Always shows the "Thats not youtube link" message, then your delphi must be broken.

drama22 31. Okt 2014 22:51

AW: Delphi and Text input
 
Zitat:

Zitat von Sir Rufo (Beitrag 1278302)
Sorry to hear that but I think your delphi is broken.

if this
Delphi-Quellcode:
if not AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end;
and that
Delphi-Quellcode:
if AnsiStartsStr('http://youtube.com', textinput.Text) then
  begin
   Application.MessageBox('Thats not youtube link', 'Info!', mb_iconWarning);
  end;
Always shows the "Thats not youtube link" message, then your delphi must be broken.

my delphi version is broken ? or the unit of System.StrUtils ?


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:30 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz