Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Logic Question

Logic Question

Logic Question

This is not specifically a FoxPro question, so much as it is a general question about how a function would work. (I know this is a lot to read but It's the best I can explain it, any help would be very gracious)
Scenario: Generating a temporary password value based on the sequence of randomly generated, 10 digit number (sounds confusing but I'll give an example after I explain how it works)

Setup: Users can set up this temporary password function with a "sequence per term", as arranged in the bottom part of the window in the following screenshot

The sequence I have set means that the user would have to enter any one of the numbers from the middle, the first, then the last number of the random code.
Example Follows:

In this sample, the user would have to enter FIRST, either a 5,3,2,8,9,1, or 4; Second, they would have to enter a 3 (first # of the code), then a 6 (last # of the code)

I sort of know where I'm going with this, and also kind of lost on how to create this function. Current thoughts is that there will have to be a FOR statement somewhere.

The settings for the sequence are stored in a table called "ptable" (contents below)

PTable has only ten records and will only ever have 10 records (1 record per term number). I know this probably isn't the best way to store them, and I'm open to suggestions on redesigning any part of this Temporary Password Function.

Thanks In Advance!

RE: Logic Question

I can't imagine why you want to generate these codes this way, but I'll assume you have a reason. I think the question you're asking is how to confirm that the code entered meets the rule. I'd think something like this:

FUNCTION TestCode(cCode)
* You'll need an index on the IdxNo field of ptable. I'm also assuming those are char, 
* not numeric

LOCAL nPos, cDigit, lSuccess

lSuccess = .T.
FOR nPos = 1 TO LEN(m.cCode)
   cDigit= SUBSTR(m.cCode, m.nPos, 1)
   IF SEEK(m.cDigit, "ptable", "IdxNo")
      IF ptable.term <> m.Pos
         lSuccess = .F.

RETURN m.lSuccess


RE: Logic Question

CODE --> vfp

Local nPos, cDigit, lSuccess
lSuccess = .T.
For nPos = 1 To Len(m.cCode)
	cDigit= Substr(m.cCode, m.nPos, 1)
	If Seek(m.cDigit, "ptable", "IdxNo")
		If ptable.Term <> m.Pos lSuccess = .F.
Return m.lSuccess 

RE: Logic Question

THanks, Koen, for the formatting. Not sure what I did wrong.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close