Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sum hours
Message
From
27/06/2005 07:10:23
 
 
To
27/06/2005 06:43:45
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01026630
Message ID:
01026654
Views:
15
hi,
i do the same steps,and set procedure to mylib
how i can use it at my program.

you mean via vfp help i can learn (procedure file).



>Hi Mohammed,
>
>I see that I wrote Set Library when I ment to write Set Procedure, sorry to confuse you. Set Library is used to add libraries written in other languages that foxpro, typically C or C++. So when I wrote Library, read Procedure. If you don't use any procedure file, I suggest you learn it, it will save you a LOT of time.
>
>>hi,
>>thank you very much,
>>sorry to bother you, this is the first time to do and learn somthing about library.
>>Ok, i do all steps,now how i can use it inside my program, not myform.
>>
>>
>>
>>
>>>Unless you follow my advice, namely to add my two functions into your library of functions, I will not help you. The reason for this, is that without a library of functions, you are re-inventing the wheel all the time, and create what is call "spagetti-code", meaning code which is extremely hard to read and debug. With a library you make every function just once, and once a function is debugged, you can forget about it. Afterwards you just use these functions, and know that you can trust your functions.
>>>
>>>If you don't have a library of functions, you are wasting a loooooot of time, both your own time, and other's time. To create a library, just Modify Command MyLib, and add my functions TimeToSeconds and SecondsToHour.
>>>To use the library, just Set Library To MyLib
>>>
>>>So, if you don't have a MyLib file (or whatever you call it), here's a start:
>>>
>>>1. Open the editor (Modify Command MyLib)
>>>2 Cut and past the next lines
>>>Function TimeToSeconds
>>>Lparameter indata
>>>Return VAL(LEFT(indata,2))*3600 + VAL(SUBSTR(indata,4,2))*60 + VAL(RIGHT(indata,2))
>>>
>>>Function SecondsToHour
>>>Lparameter indata
>>>Return PADL(INT(indata/3600), 6, "0") + ":" + PADL(INT((indata%3600)/60),2, "0")
>>>3. Save the file
>>>4. Add the line
Set library to MyLib
to the init of your form. Or add it before
>>>Do form xxx
>>>Read Events
>>>Personally I also include the line in my Startup.prg file, so I can always use the functions.
>>>
>>>>hi,
>>>>the first part,the result is 000000:01
>>>>second part nothing, maybe i use it with rong way
>>>>the third part,i get error message data type mismatch
>>>>
>>>>i need to use this code with this code under
>>>>
>>>>USE curbilldata
>>>>
>>>>DO WHILE NOT EOF()
>>>>     m.divi = curbilldata.divi
>>>>     DO WHILE m.divi = curbilldata.divi AND NOT EOF()
>>>>          SKIP
>>>>     ENDDO
>>>>
>>>>
>>>> IF NOT EOF()
>>>>          m.lnCurRec = RECNO()
>>>>          INSERT BEFORE BLANK
>>>>    SUM VAL(LEFT(m1_m,2))*3600 + ;
>>>>    VAL(SUBSTR(m1_m,4,2))*60 + ;
>>>>    VAL(RIGHT(m1_m,2)) TO lnSec for m.divi = curbilldata.divi
>>>>m.dae= PADL(INT(lnSec/3600), 6, "0") + ":" + ;
>>>>      PADL(INT((lnSec%3600)/60),2, "0")
>>>>
>>>>
>>>>
>>>>          GOTO m.lnCurRec
>>>>           replace m1_m WITH m.dae
>>>>           SKIP &&& i get error
>>>>     ENDIF
>>>>ENDDO
>>>>
>>>>
>>>>thanks
>>>>
>>>>>More typos:
>>>>>SUM VAL(LEFT(m1_m,2))*3600 + ;
>>>>>    VAL(SUBSTR(m1_m,4,2))*60 + ;
>>>>>    VAL(RIGHT(m1_m,2)) TO lnSec
>>>>>m.dae= PADL(INT(lnSec/3600), 6, "0") + ":" + ;
>>>>>      PADL(INT((lnSec%3600)/60),2, "0")
>>>>>However, I STRONGLY recommend that you add a TimeToSeconds function to your library:
>>>>>Function TimeToSeconds
>>>>>Lparameter indata
>>>>>Return VAL(LEFT(indata,2))*3600 + VAL(SUBSTR(indata,4,2))*60 + VAL(RIGHT(indata,2))
>>>>>And a SecondsToHour function:
>>>>>Function SecondsToHour
>>>>>Lparameter indata
>>>>>Return PADL(INT(indata/3600), 6, "0") + ":" + PADL(INT((indata%3600)/60),2, "0")
>>>>>This way your formula will be:
>>>>>m.dae=SecondToHour( TimeToSeconds('34:20') + TimeToSeconds('36:40') + TimeToSeconds('71:10') + TimeToSeconds('66:10'))
>>>>>Remember, it's much more readable to create a library of functions, and use these functions, instead of using the complete formulas many places.
>>>>>
>>>>>
>>>>>>hi,
>>>>>>i try it before, i get result 210:28
>>>>>>the result must be 208:20
>>>>>>
>>>>>>thank you.
>>>>>>
>>>>>>>>hi all,
>>>>>>>>i try to sum this hours and minuts via this code under , it sum hours ok,
>>>>>>>>somthing rong with minuts
>>>>>>>>ex:34:20+36:40+71:10+66:10 the result must be 208:20
>>>>>>>>
>>>>>>>>via this code under i get 208:44
>>>>>>>>
>>>>>>>> SUM VAL(LEFT(m1_m,8))*3600 + ;
>>>>>>>>            VAL(SUBSTR(m1_m,6,2))*30 + ;
>>>>>>>>            VAL(RIGHT(m1_m,2)) TO lnSec
>>>>>>>>          m.dae= PADL(INT(lnSec/3600), 6, "0") + ":" + ;
>>>>>>>>                 PADL(INT((lnSec%3600)/60),2, "0")
>>>>>>>>
>>>>>>>>thanks.
>>>>>>>
>>>>>>>I see a typo in your formula, change 30 to 60! 60 is for 60 minutes in an hour, 30 means nothing.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform