Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 28th, 2004, 12:55 PM
Gavin83's Avatar
Gavin83 Gavin83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 295 Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 8 h 19 m 58 sec
Reputation Power: 45
Pascal validation problem

I couldnt see a forum for Pascal, so I thought this would be the best place to put it.

In the script Im using, I have a variable called name, that contains the persons name. Now, I want the script to return an error if any numbers are entered in the variable.

I was told the only way to do this was to break it down into an array of each letter and then check each one for a number. Now, if anyone could find another way, or write me a few lines that would do the above, Id be most grateful.

Reply With Quote
  #2  
Old January 28th, 2004, 04:44 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,381 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 24 m 14 sec
Reputation Power: 4080
Depends on how strict your pascal compiler (or your professor) is . Standard Pascal as defined by Niklaus Wirth didn't have a string type. Turbo Pascal did add a string type extension to the language. So you might want to tell us how you've defined the variable "name". The following should work somewhat on Turbo Pascal (untested code)
Code:
Function IsOk(name : string) : boolean;
var
   i: integer;
begin
    IsOk := false;
    for i := 1 to Length(name) do
    begin
        ch := name[i];
        if (ch in ['0'..'9']) then
        begin
            IsOk := true;    
            i := Length(name);
        end;
    end;
end;

Note: I didn't use the Break or Result keywords as they're specific to Delphi, not Pascal.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Reply With Quote
  #3  
Old January 28th, 2004, 06:01 PM
Gavin83's Avatar
Gavin83 Gavin83 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 295 Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level)Gavin83 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 8 h 19 m 58 sec
Reputation Power: 45
Yeah, its slowly working with a little bit of reworking. Thanks for your help.

One more thing. Can I create a statement that allows me to print the page?

And yes, Im using Turbo Pascal.

Reply With Quote
  #4  
Old January 29th, 2004, 12:38 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,381 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 20 h 24 m 14 sec
Reputation Power: 4080
Been a while since I did any turbo pascal programming for DOS, but IIRC, issuing an INT 5 interrupt intstruction would cause the BIOS to print screen. In Turbo Pascal, you would fire off the interrupt like this:
Code:
Intr ($5);


However, if you want to send all the output to the printer, there are a couple of ways to do it. First you could redirect your program output to the printer like this:
C:\> program > prn

Second, if you know how to write to files, you could open a file called "prn" which would access the printer. Then you write to it just like you write to any other file and it will print on the printer. Don't forget to hit form-feed at the end, if you're not using a dot-matrix (now I'm showing my age ), otherwise some printers will not eject the page.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Pascal validation problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap