Thanks for the info. Ken. I will try and get back in case I have any issues. Thanks for your time. With regards, Chandru. > Give it a try and find out for yourself. Try putting this simple function definition into any method in the report's DE. >
> FUNCTION Test
> RETURN "Hello World"
> ENDFUNC
> The second to close the method window it gives you an error. If this were a form, you would simply add a custom method and define your function as a method instead of a function. The same rules exist in a report - but in a report, you cannot create a custom method. The only way to do this is with SET PROCEDURE TO FileName.Prg > > Ken > > > Thanks Ken for the details. > > > > As I understand I suppose I can do these in BeforeOpenTables and CloseTables events of Data Environment. Could you please confirm whether my understanding is correct? > > > > Thanks, > > With regards, > > Chandru. > > > Create a new .Prg file and enter the function definition using the commands: > > >
> > > FUNCTION MyFunctionName
> > > LPARAMETERS lParmaeter1, lParameter2 ...
> > > ... && Enter the code for the function here
> > > ENDFUNC
> > >
> > > && When you want to use the function,
> > >
> > > SET PROCEDURE TO YourFunctionsProgram.Prg
> > >
> > > && When done using the function,
> > >
> > > SET PROCEDURE TO
> > >
> > > > > > I have a MyAppProcs.Prg file for each app. This program contains all of the functions and procedures that I use in the app. Doing it this way, I can SET PROCEDURES TO MyAppProcs.Prg in my Main.Prg and then forget about it until ON SHUTDOWN. > > > > > > Ken > > > > > > > Thanks for the reply Ken. What you say is the one I want to do. > > > > > > > > I tried to set the function what you said. I could not define it. Though the problem got resolved by the way I used Foxhound's suggestion, I do would like to know how to define this (i.e. as you said.... set the controlsource of this textbox to a function) in MS Visual Foxpro 6.0. I would think this would also be useful. Could you please tell me how (Steps..) do I define a function like you mentioned in the mail? > > > > > > > > Thanks, > > > > With regards, > > > > Chandru. > > > > > If TimeIn or TimeOut are NULL, you want to print nothing. If NEITHER of these variables are NULL, you wish to compute and display the difference. OK > > > > > > > > > > In your report, set the controlsource of this textbox to a function and change the "Print When" to "> 0" > > > > >
> > > > > FUNCTION MyFunction
> > > > > LPARAMETERS ltTimeIn, ltTimeOut
> > > > > IF ISNULL(ltTimeIn) OR ISNULL(ltTimeOut
> > > > > RETURN 0
> > > > > ELSE
> > > > > RETURN (ltTimeOut - ltTimeOut)
> > > > > ENDIF
> > > > > ENDFUNC
> > > > >
> > > > > > > > > > Ken > > > > > > Thanks for the info. Foxhound. > > > > > > > > > > > > I have tried this and also added as Ken has mentioned about when to print. I am getting blank now where it is null. Unfortunately, I am not getting values printed when there is value. Let me explain what I am trying to do. > > > > > > > > > > > > As mentioned I have 2 date fields in a table. I need to print the difference in them like whatever the date-time difference (eg. 0.05 hrs. etc.). Since either both or one of them could be null, I have defined variable for which I use expression (as mentioned by you I used those expression) to make sure either I have 0 or the value of the field. I use in turn this variable to find the difference like (t1out - timesheet.t1in). Though both t1out and timesheet.t1in has values, I am getting blank in the report. I have tried using the format(##.##) as well with no change. > > > > > > > > > > > > Thank you Ken, Foxhound for your help. > > > > > > > > > > > > Thanks, > > > > > > With regards, > > > > > > Chandru. > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > > > > > I want to get the difference in 2 date fields stored in a table. Dates in the table can be stored as .NULL. To use this in a report, I have defined 2 variables and used "iif((timesheet.t1out =.NULL.), 0, timesheet.t1out)" to make sure either the variable is 0 or contains a valid date. But when I print the variable, I keep getting .NULL. printed and not 0. > > > > > > > > > > > > > > > > Could you please tell me how to do this? > > > > > > > > > > > > > > > > Thanks in advance, > > > > > > > > > > > > > > > > Thanks, > > > > > > > > with regards, > > > > > > > > Chandru. > > > > > > > > > > > > > > Because expression timesheet.t1out =.NULL. will also return 'null' value, not 'true' value > > > > > > > > > > > > > > null=null ---> null (not True) > > > > > > > > > > > > > > > > > > > > > use ISNULL() function > > > > > > > > > > > > > >
> > > > > > > iif(ISNULL(timesheet.t1out), 0, timesheet.t1out)
> > > > > > >
> > > > > > > but I think it might give you another error, because 0, is not Date data type. You may want to try this instead > > > > > > > > > > > > > >
> > > > > > > iif(ISNULL(timesheet.t1out), {}, timesheet.t1out)
> > > > > > >
> > > > > > > > > > > > > > > > > > > > > FoxHound > > > > > > > --------------------------------------------------------- > > > > > > > It’s not what you had achieved yesterday, nor what you are going to achieve tomorrow. But what you are achieving today define your success.
|