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!

problems with understanding source code

Status
Not open for further replies.
Jan 28, 2007
2
DE
I have just started programming in VFP 9.0.
-
I found this function in a sample code:
M.LIWRDAT = DATE()+3

1.)What's the format of the date? 22.01.07 or does it take a value from the past?
-
I'm also uncertain about this code:
M.MODULES = "1 2 3 6 "

Why does the author put 'spaces' between the numbers? What'S the reason for this?

Thank you in advance!

Best Regards
mario
 
VFP have a very powerful engine to work with DATES and strings, so
1 - M.LIWRDAT = DATE()+3
That means that in LIWRDAT variable is stored value 3 days ahead from today. No matter what is your current SET DATE setting this value always is 3 days from today:
if today is {2007-01-22} (yyyy-mm-dd format) that variable will have: {2007-01-25} as value

>I'm also uncertain about this code:
>M.MODULES = "1 2 3 6 "

I don't know WHY this variable is defined that way, but this is a simple STRING variable with some value in it. maybe the code after that will tell you WHY it is defined that way.


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Mario,

First, welcome to the forum, and also to Visual FoxPro. as you are probably finding, it can be quite a daunting language, but it is worth persevering with.

Just to add to Borislav's reply:

The DATE() function tells you today's date. The date format is irrelevant.

DATE + 3 adds three days to the above date.

M.LIWRDAT = DATE()+3 stores the result (today plus three days} in a memory variable called LIWRDAT. The M. in front of the variable name is just to emphasis that this is a memory variable rather than a field (in this context, M. is redundant because LIWRDATE can only be a variable).

M.MODULES = "1 2 3 6 " This takes a string, consisting of four digits with spaces between, and stores it in a variable called MODULES. As for the reason for the spaces, you'll have to figure that out from the rest of the code.

I hope this helps. Be sure to come back when you have more questions.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
>I'm also uncertain about this code:
>M.MODULES = "1 2 3 6 "

Best guess: this value is stored in the variable m.modules as the programmer was doing an INLIST(), $ , Substr(), Strextract() etc and the spaces help with the Occurance flag.
Or the value "1 2 3 6 " refers to something
Though there is No need for the spaces for inlist() or $ . If you have copied the code accurately, do you notice a space after 6 and "
Best suggestion if the author is available ask him/her.
 
Though there is No need for the spaces for inlist() or $

I'd leave the spaces in for now because it means we can tell the difference between "1 2 3 6" where "1" and "2" are included and "12 3 6" where "12" is included. It might also be that the original programmer is searching this string for a digit surrounded by spaces so that they don't get a false match by picking the "23" when searching for "2".

I don't know whether either of these are going to be important in this particular application but you might introduce a bug if you take the spaces out.

Geoff Franklin
 
That's is absolutely correct as well. Strange though... Hundreds of ways to skin a cat...though I am sure the cat would not appreciate any of them.
 
Thanks for the friendly welcome and the answers!
Maybe it would help me if I could use the debugger of visual Fox pro 9.0. Can anyone tell me how to use it?
I selected the compiled EXE, but the debugger says 'Source not available'

Thanks for help again.

 
The debugger works on forms and programs, etc. Open up the project, place breakpoints in the the code/form methods, etc. where you want to investigate things and then run the Main.Prg. When execution reaches a breakpoint, your debugger will appear. If it doesn't select Tools->Debugger in the VFP menu.
 
There were 23 single-line ways of putting "Hello World" on screen

And you can break every one of them by setting _Screen.Font="Wingdings" ;-)
 
The Debugger only works at design-time, not at runtime. That is, if you're running the EXE outside the VFP environment, you don't have access to the Debugger.

Tamar
 
you're running the EXE outside the VFP environment, you don't have access to the Debugger.

True, eg Set Step On will not work then, causing no error if ASSERT is set off and causing error 1001 - feature is not available otherwise.

You could DO main.prg IN Some.EXE from a VFP IDE and then have a debug run. But that does not cause _vfp.startmode=2. Include debug info when ompiling and you're able to get info out of Message() and Message(1) and Lineno(), or ASTACKINFO(), that already helps a lot.

I do debugging in the IDE with the unlinked project components, and I think it's a great advantage you do not need to build it before you can debug.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top