Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

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 ASP Free Forums Sponsor:
  #1  
Old May 12th, 2007, 02:57 AM
xelo xelo is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 1 xelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m
Reputation Power: 0
Can somebody help me?

Ok. I have a slight problem...
The code i have is not based on any type of coding it just is a rough so that i can later re-encode it to work in a different language but i am struggling to get the correct err().
The function err(1) to err(5) is either true or false depending on what has been entered in the first place. The code is really simple its just i can't get my head round which way will it be correct or false.

here is my code:

Code:
1 Input code; length = Len(code)
2 For index = 1 To 5; err(index) = False; Next index
3 error = False
4 If length = 0 Then
5 Output “Empty string is not allowed”
6 error = True
7 Else
8 If length <> 5 Then
9 Output “The string should be 5 characters long”
10 error = True
11 Else
12 ch1 = 1st character of code; ch2 = 2nd character of code
13 ch3 = 3rd character of code; ch4 = 4th character of code
14 ch5 = 5th character of code
15 If ch1 < “0” Or ch1 > “9” Or ch2 < “0” Or ch2 > “9” Then
16 err(1) = True
17 If ch1 < “A” Or ch1 > “Z” Or ch2 < “A” Or ch2 > “Z” Then
18 err(2) = True
19 End If
20 Else
21 err(2) = True
22 End If
23 If ch3 < “0” Or ch3 > “9” Then err(3) = True End If
24 If ch4 < “0” Or ch4 > “9” Then err(4) = True End If
25 If ch5 < “0” Or ch5 > “9” Then err(5) = True End If
26 If err(1) And err(2) Then
27 Output “Invalid country”
28 error = True
29 Else
30 If err(1) Then
31 Output “Overseas Centre”
32 Else
33 Output “UK Centre”
34 End If
35 End If
36 For i = 3 To 5
37 If err(i) Then
38 Output “Invalid”, i, “th character”
39 error = True
40 End If


ok so for example if i input

MV394
i will get the following (i think please do tell if i am going wrong)

err(1) is True
err(2) is False
err(3) is False
err(4) is False
err(5) is False

and the variable error will be:

error = False

Now i am not sure this is correct because i am still kinda confused.... Some dude wanted me to have a look at it to help him but i am baffled (just a little bit of a n00b i know..)

so my question to you is what would be the output considering the code is case sensitive for:

K93621

(i think its all false apart from the error var as it needs to be True)

and

Ab149

(Same here.. But am not sure... Please help)



I thank thee in advance,
THANK YOU!!
xelo

Last edited by Lafinboy : May 12th, 2007 at 03:37 AM. Reason: Added code tags

Reply With Quote
  #2  
Old May 13th, 2007, 02:18 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information.
 
Join Date: Sep 2004
Location: Israel
Posts: 26,906 Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 8th Grade (Above 100000 Reputation Level)  Folding Points: 338585 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338585 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338585 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338585 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338585 Folding Title: Super Ultimate Folder - Level 1Folding Points: 338585 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 5 Days 8 h 17 m 44 sec
Reputation Power: 1537
--moved to the general Programing Help forum, that's not ASP nor VB.

hello and welcome to aspfree,
here is more readable version of the code with indentation:
Code:
Input code;
length = Len(code);

For index = 1 To 5
	err(index) = False;
Next index

error = False
If length = 0 Then
	Output “Empty string is not allowed”
	error = True
Else
	If length <> 5 Then
		Output “The string should be 5 characters long”
		error = True
	Else
		ch1 = 1st character of code; ch2 = 2nd character of code
		ch3 = 3rd character of code; ch4 = 4th character of code
		ch5 = 5th character of code
		If ch1 < “0” Or ch1 > “9” Or ch2 < “0” Or ch2 > “9” Then
			err(1) = True
			If ch1 < “A” Or ch1 > “Z” Or ch2 < “A” Or ch2 > “Z” Then
				err(2) = True
			End If
		Else
			err(2) = True
		End If
		If ch3 < “0” Or ch3 > “9” Then
			err(3) = True
		End If
		If ch4 < “0” Or ch4 > “9” Then
			err(4) = True
		End If
		If ch5 < “0” Or ch5 > “9” Then
			err(5) = True
		End If
		If err(1) And err(2) Then
			Output “Invalid country”
			error = True
		Else
			If err(1) Then
				Output “Overseas Centre”
			Else
				Output “UK Centre”
			End If
		End If
		For i = 3 To 5
			If err(i) Then
				Output “Invalid”, i, “th character”
				error = True
			End If
		Next i
	End If
End If

for the input of "K93621" it's really obvious: as it's not 5 letters you'll
get output "The string should be 5 characters long" and error will be true.

with "Ab149" it's bit more tricky: err(1) will be True because "A" is not
between 0 and 9 and err(2) will be True because "b" is not between
"A" and "Z". the rest are digits, thus err(3) to err(5) will all stay False.
final output will be "Invalid country" and error will be true.

all in all, this pseudo code analyze input string and expect it would
start with two big case letters (A to Z) followed by 3 digits.
hope this now makes more sense.

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Can somebody help me?


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway