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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While there is any .f. (false logical records) in the table, do something, if there isnt any, do something ekse

Filip Brnic

Programmer
Dec 25, 2023
49
RS
Hello, i need a command button that does something only if there isnt ANY .f. in the table
I need this because i dont wanna allow someone to go further into my program without accounting some stuff.
Does anyone have any idea how i would do this??
 
No further details? No field names? Any field? I mean if it's known anyone can create a DBF file and put the necessary .F. in it to get through your barrier.

Here are some considerations about security in FoxPro: http://www.foxpert.com/docs/security.en.htm

I won't continue with code samples, because I'm quite sure, though I could be wrong, that you mean something else than you wrote, just judging by the number of negations you use to formulate your requirements. That's a bad sign, alone. Formulate what you want, not what you don't want. You can even take that as a much more general advice, concentrate on formulating this positively, not with double, triple of quadruple negations.

I think what you need is an entry point knowledge of cryptography. The Foxpert article isn't that, it focusses on some simple but astonishing weaknesses in VFP code processing and warns how they could be exploited and points out how to code to avoid these weaknesses. It's a good starting point, though it's very specifically about VFP only. A bit more general at least basic cryptography knowledge will give you better ideas on how to go about application security.
 
Well i made it sound incredibly harsh if someone happens to go trough the program, the program itself isnt done to that extent, but i do have to tell you more, i have a field (knjizeno) which is logical, if there is anything in that column that is .f. then i want it to do something, and vice versa, if someone does bypass they will eventually run into more problems in the code so i just wanna know for now how to on-click check if there are any .f. in records of the table.
 
There are lots of ways to do this. If you don't mind moving the record pointer in that table:

Code:
LOCATE FOR NOT knjizeno
IF FOUND()
   * Don't allow the user to continue
ENDIF

or:

Code:
COUNT TO nFalse FOR NOT knjizeno
IF nFalse > 0
   * Don't allow the user to continue
ENDIF

You could also use a SQL query, which would leave the record pointer alone:

Code:
SELECT knjizeno ;
  FROM YourTableNameHere ;
  WHERE NOT knjizeno ;
  INTO CURSOR csrFalse
 
IF _TALLY > 0
   * Don't allow the user to continue
ENDIF

I can think of a bunch more, but that's probably enough. And, if you go with one of the record-pointer moving approaches, you should probably save and restore its position.

Tamar
 
Not sure, it sounds like you note down in that data what parts of the program are finished, and if one part isn't, would prevent to run it. Wouldn't it be simpler to not release something unfinished, then?

It doesn't sound like a authentication problem anymore, but the intent is still not something that sounds plausible to me. If you want to prevent code to run with an incomplete configuration or a configuration that you identify as wrong by verification rules, that would be something I would encourage to do as a mechanism to prevent errors. But then, your data about the parts of finished code can be wrong.

The usual way to determine when a program is ready for production use is testing, and that is a topic in itself, again.
Tip: Look into https://github.com/VFPX/FoxUnit. This generates result files and returns an overall result by exitcode 0 for successful testruns and 1 (aka ERRORLEVEL 1) for an overall failed test.
 
Last edited:

Part and Inventory Search

Sponsor

Back
Top