Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logic Question

Status
Not open for further replies.

TGrahmann

Programmer
Feb 19, 2015
43
US
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
Passwd_h9wnbd.png

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:
EntPW_y6cqrx.png

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_mnplwd.png

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!
 
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:

[pre]
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.
EXIT
ENDIF
ENDIF
ENDFOR

RETURN m.lSuccess
[/pre]

Tamar
 
Code:
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.
			Exit
		Endif
	Endif
Endfor 
Return m.lSuccess
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top