Page 2 of 2

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 2:19 am
by Danilo
oldefoxx wrote:Take recursion, a topic I spoke on yesterday.
Why don't you write a book that contains all of your knowledge? Maybe Norton Guide format or .pdf e-book?
A chapter about recursion, another chapter about consoles, LFN double quote tricks, etc.

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 3:16 am
by juror
Danilo wrote:
oldefoxx wrote:Take recursion, a topic I spoke on yesterday.
Why don't you write a book that contains all of your knowledge? Maybe Norton Guide format or .pdf e-book?
A chapter about recursion, another chapter about consoles, LFN double quote tricks, etc.
He is. You've already been subjected to parts of it. :)

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 6:17 am
by oldefoxx
A book for what? I'm just taking what is going on, what passes before my eyes, and
what other people are going through and trying to take it to the next level. Since I
got introduced to computers by the Navy back in 1966, I've been taken with the idea
that computers are the ultimate game, not writing games, not playing games, but
challenging yourself to get something done with them by programming them to do
things you haven't done with them before. You know computers have no concept oif
self, no awareness of the world around us, no ID and no IQ. Now get that machine to
do something that impresses other people, and maybe you accomplished something.
Work at it hard enough, and you may impress yourself.

Take the calendar for instance. Everybody knows that every fourth year is a leap year,
and that that year we have 366 days rather than the cystomary 365 days. But it is all
based on the earth's orbit around the sun, how long it takes to get back to the same
spot again. And the orbit varies somewhat. And the interval is not precisely 365.25
days anyway, just close to that. So how do we adjust for that? Well, several ways:
Every 100 orbits about the sun (100 years), we skip the leap day. That is still not exact,
so every 400 orbits about the sun (400 years), we forget the 100 year rule and have a
leap day anyway. Still not quite perfect, so what we should have done in 2000 was
skip another leap year, and do that every 2000 years until we reach the year 20,000,
which would again be a leap year. How do I come up with these numbers? I researched
the matter of the earth's orbit about the sun, and then worked out the numbers. The
thing is, the orbit is going to change over time, especially a long time, and we don't
control that, we are just observers.

So I know what the calendar should be, but the matter is subject to commonality with
others, because to a degree all our lives are regulated by the clock and the calendar. So
instead of writing a calendar program that observes all these rules, I write one to only
recognize and obay the 4-, 100-, and 400-year rules. That is what everybody else goes by.

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 6:45 am
by Danilo
Cool, thanks for the background information! Do you write the calendar program
by using WinAPI or plain PureBasic? Console or GUI calendar?

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 8:19 am
by oldefoxx
The process of doing the calendar is fairly simple. If you are going to do the date and
time of files, you may need the APIs, although you can strip the information out of a
capture of the command line DIR instruction.

Most dates here in the States are written mm/dd/yyyy. I recall from years ago that the
date elsewhere may be yyyy/mm/dd or even dd/mm/yyyy. You may also have a case
were the year is only two digits. Because of these variations, you may have to either
get clarification of the date being checked for, or shuffle the entries for each about until
you have them where dd is the day of the month, mm is the month of the year, and yy is
the year itself. Here I am assuming that dd, mm, and yy are integers.

With FileTime, you may also want to work down into the hh:mm:ss level as well. That
is easy enough to do, but since you are then going to have to multiply the daycount by
24*60*60 to get to the second level, you will have to build the result up as a quad, not just
as a long. Turns out there are 86,400 seconds in a single day. Oh, and since we are already
using mm for the month, we will use mt for the minute while hh is the hour and ss is the
second.

Let's assume you want it to the second, meaning a quad output, Now it's late, and I don't
want to spend the night on this, so I will provide just an outline. We are going to use dtc
as our DateTimeCount accumulator.

Code: Select all

mm.l=val(a$)       ; a$ holds the date and time
a.i=FindString(a$,"/")
dd.i=Val(Mid(a$,a+1))
a=FindString(a$,"/",a+1)
a$=Mid(a$,a+1)
a=FindString(a$," ")
yy.i=Val(left(a$,a-1))
hh.i=Val(Mid(a$,a+1))
a=FindString(a$,":",a)
mt.i=val(Mid(a$,a+1))
a=FindString(a$,":",a+1)
ss.i=Val(Mid(a$,a+1))
If mm > dd and mm>yy      ;apparently the provided date was in yyyy/mm/dd order
  a=mm         ;this will be the year
  mm=dd       ;this is now the month
  dd=yy          ;this is now the day
  yy=a            ;now we set the year
EndIf
dtc.q=dd  
If mm<3        ;leap year not an issue if this is months January or February
ElseIf Mod(yy,400)=0
  dtc+1
ElseIf Mod(yy,100)=0
ElseIf Mod(yy,4)=0
  dtc+1
EndIf
Select Case mm
Case 2
  dtc+31
Case 3
  dtc+59
Case 4
  dtc+90
Case 5
  dtc+120
Case 6
  dtc+151
Case 7
  dtc+181
Case 8
  dtc+212
Case 9
  dtc+243
Case 10
  dtc+273
Case 11
  dtc+304
Case 12
  dtc+334
End Select
dtc+Int(yy*365.2425)    ;at this point you have the daycount
dtc*24
dtc+hh
If hh<12 and FindString(a$,"p")>0
  dtc+12
EndIf
dtc*60+mt
dtc*60+ss                      ;at this point you have your datetimecount to the second
I haven't tested the above code in PureBasic, and am a bit concerned that the
Mod() function specifiies it works with floats or doubles, and I am using integers.
If that doesn't work, I could write my own iMod() function to do the job.

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 9:29 am
by c4s
oldefoxx wrote:Most dates here in the States are written mm/dd/yyyy. I recall from years ago that the
date elsewhere may be yyyy/mm/dd or even dd/mm/yyyy.
You say it may be different? Well, as with the customary system for weights etc. the system you are talking of is only in the USA!
oldefoxx wrote:Take the calendar for instance.[...]

Code: Select all

; no WinAPI code
No this doesn't belong here. As it has been said to you numerous times before: Please stop that!

Learn our forum rules, write less, stay on topic... after all this is a programmers forum, for PureBasic!

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 10:37 am
by Danilo
removed

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 11:50 am
by luis
danilo wrote: @c4s: He is 72 and retarded, so please bear with him. It may be the last month/chapter of his life.
It can be the last one for us too. Always pay attention when you cross a street.

Apart that, he clearly write too much (for this kind of forum) and in a non focused way. He's rambling about computer and programming like he's having a tea with some relative who works in another field.
Some things he says, especially from the historically point of view, can be interesting (at least to me), but probably he should developing his ideas in general discussions, where anyone interested can follow.
Polluting the threads with these long-winded posts stating the obvious (for many of us anyway) I fear it will not do any good to anyone and especially to him in the long run.

@oldefoxx: If I may, try to be a little more concise and to the point, I stopped reading your posts simply because there are too convoluted and unnecessary long. I didn't want to but they are distracting when following a thread. There is a time for relaxed talking, but there is a place also. For example "general discussions".
It's only a suggestion, but think about it. See ya.

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 6:32 pm
by LuCiFeR[SD]
hehe, the geek side of me finds what oldefoxx writes damn interesting :P but, I hate saying but, because it just sounds like I am ready to put the boot in lol.... Oldefoxx, I would love to hear more of your stuff, but perhaps off topic would be a better place to post? :)

Re: Windows Programming: Learning more about the Win32® API.

Posted: Mon Sep 24, 2012 8:27 pm
by idle
yes this is way off topic and in a sticky thread to boot!

Re: Windows Programming: Learning more about the Win32® API.

Posted: Thu Sep 27, 2012 7:15 pm
by oldefoxx
Danilo wrote:Cool, thanks for the background information! Do you write the calendar program
by using WinAPI or plain PureBasic? Console or GUI calendar?
The calendar program is written in PureBasic. No APIs needed. I wrote straight line
code in a previous post, but for myself, I wrote two procedures: DateTime2Count(),
and Count2DateTime(). Actually, it can be written just to the calendar day level,
in which case drop everything about hour, minute, and second and call the procedures
Date2Count() and Count2Date().

You might have noted that the best multiplier for converting yyyy to days is 365.2425,
not the 365,25 most people expect. 365.25 only allows for a yeap day added every four
years. 365.2425 allows for dropping a leap day every 100 years, and adding it back
every 400 years. Make sure you take the integer value of the result. As a procedure, called
with a parameter to process, it makes no difference if using Console or GUI Calendar.

The Count2Date or Coun2DateTime processes are nearly exactly the reverse of the initial
Date2Count or DateTime2Count methods. It's right both ways when you randomly or
sequentially generate figures that cover a large range of dates and come back with the same
results on both ends.

Date & Time would be helpful in deciding which copy of a file is newer/older. Date would be
helpful if calculating forward or backwards a certain number of days, or calculating how many
days between two calendar dates.

Re: Windows Programming: Learning more about the Win32® API.

Posted: Thu Sep 27, 2012 7:25 pm
by oldefoxx
luis wrote:
danilo wrote: @c4s: He is 72 and retarded, so please bear with him. It may be the last month/chapter of his life.
It can be the last one for us too. Always pay attention when you cross a street.

Apart that, he clearly write too much (for this kind of forum) and in a non focused way. He's rambling about computer and programming like he's having a tea with some relative who works in another field.
Interesting observations, from a distance of course. I'm actually only 71, and though
I suffered a head injury about five years back, I'm managing pretty well for a guy
that has no real sense of balance.

Good to remember that life has few guarantees, and with the way the money is flowing
out of the printing presses these years, you can expect a severe come-uppance to result
in a severe setback for everyone in a few short years. Not just my thoughts on the
subject, check it out for yourselves.