PDA

View Full Version : GetTickCount



Yann_F_29
20-04-2021, 01:20
Hi ,


I wonder what is the type of the number returned by the GetTickCount function.

long ? quad ? or other ?

I think this info should be in help ;)

Best regards.

Yann

ReneMiner
21-04-2021, 01:26
you could find out using SizeOf( GetTickCount) - if 4 its a 32Bit integer, 8 were 64Bit Integer Type , 10 if it were a number or 16 in case Variant

Yann_F_29
21-04-2021, 18:28
Hi René

Sorry the SizeOf function does not work with FUNCTIONS but on VARIABLES or VARIABLES TYPE as documented in Sizeof manual page.

So the topic still needs expert answer.

Conversly the HiResTimer_Get help page is documented ( it's a QUAD)

Regards

Yann

ThinBasic v=1.11.1.0

chameau
21-04-2021, 23:06
Sorry it's a mistake
I don't know how to delete a message.

François

ReneMiner
23-04-2021, 18:08
Hi René

[QUOTE=Yann_F_29;96013]Hi René






Sorry the SizeOf function does not work with FUNCTIONS but on VARIABLES or VARIABLES TYPE as documented in Sizeof manual page.






So the topic still needs expert answer.

Conversly the HiResTimer_Get help page is documented ( it's a QUAD)

Regards

Yann

ThinBasic ;v=1.11.1.0



you actually do not want to know the SizeOf(returned GetTickCount-result)


but the TypeOf(result returned by GetTickCount)


GetTickCount() is a Win32-API-Function. It returns a signed 32Bit integer (use Long or Int32 in thinBasic) which is the time in milliseconds since the computer powered up.
It is known to be updated in a range bit above 20ms avarage and as precise as a bend ruler.
It can respond maybe 50 times a second at most if windows is not busy that much...
Can be you wait 3 seconds without any update of GetTickCount


-while windows is busy contacting the microsoft-server to download some new malware-definitions or to upload your data for investigation-


It serves to create a timer that tells you when the coffee maker is done and you can go to the kitchen and fetch some coffee or when the pizza in your oven is ready


HiResTimer is something different, not based on the Win32-ticks


it does not return 1 000 MILLIseconds per second but 1 000 000 MICROseconds and responds instantly while getTickCount has to wait until Windows message service has time to proceed your request.




And Yes you are right sizeOf() will not return the sizeOf( a function )


thats what anyone thinks who is used to compiled programming languages...
how- were it the bytes of the functions body text to count?
Before or after compilation?


In compiled programming languages that will just say:


ERROR - Type mismatch


Some developers have the ugly habit to be very precise when returning a result and think about what the user might pass as a parameter besides the expected and develop dozens of new Error-message rather than to avoid any Errors i.e. when their developed function returns only what is commonly understood as the sizeof()-parameter must be a type or a variable and nothing else can be accepted.


Sizeof() developed-with it a Bit of flexibility in mind inbetween the Bytes -


when the passed parameter were no variable, no VarPtr and no Type -
but a function, property or method or Function-Pointer
- it will just result the size of the return type
- or zero if it were a sub.




The language reference also is not always up to date -what is not in help file might be developed already. Thinbasic is always good for a surprise - many times i wondered when it was so obvious that something should work a certain way and i found it did it already.


Commonly new functions are tested in a Alpha- or Beta-Versions and sometimes need re-adjustment or changes in syntax or parameters so before they are not working and tested to be correct no one will announce it in help but ask in forum for testers...


...and when it comes to a release candidate --- who has time not only to develop and fix everything and not to forget any updates in the documentation while the users are staring onto their screens and wait the moment for the update or hotfix to be online...