HELP! Unsigned #'s

 BBS: Inland Empire Archive
Date: 11-23-92 (11:37)             Number: 380
From: LUIS ESPINOZA                Refer#: NONE
  To: TOM HAMMOND                   Recvd: NO  
Subj: HELP!  Unsigned #'s            Conf: (2) Quik_Bas
On (19 Nov 92) Tom Hammond wrote to All...

 TH> Help!
 TH> I was confused that the value of this variable appeared to be a
 TH> negative
 TH> number.  Looking into the actual file, I found that the two bytes were
 TH> &H73 and &H84.  I assumed that the two bytes were stored LOW HIGH, so
 TH> I
 TH> reversed their position and ran them through a HEX-to-DEC calculator
 TH> to
 TH> obtain a confirmation of what I'd previously printed out.  The
 TH> calculated value was 33907....  NOT the -31629 I'd come to expect.

        Well you see Integers have a value of -32768 to 32767, with the
        high bit being the sign (0 for pos, 1 for neg) so anything below
        0x8000 (32768 decimal) is considered positive everything else is
        considered negative.
        The best way to handle this little situation is by treating it
        as a hex number, unless you know the bit masks for each of the
        data contained in the word. (which bits makes up day/month/year)
        It is quite possible that you could use the routine that was
        posted here a while back for dos file date/time stamps!

                                                        Luis


 TH> I'll be happy to provide as much additional supporting info as I can
 TH> if
 TH> that is necessary.
 TH>
 TH> Thanks!
 TH>
 TH> Tom Hammond   (note: NO hair) ===>   (:-(

        Here is the routine that was posted:
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
 Area:    QUIK BASIC
 Date:    04 Nov 92  16:50:50  Public
 From:    Tony Elliott
 To:      Robert Church
 Subject: Re: File's date and time in DOS DTA
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
 -=> Quoting Robert Church to All <=-

 RC> How do I get the date and time from the Dos DTA?  I've got the DTA
 RC> structure and the FindFirst/FindNext routines, but how do I convert
 RC> the bit-mapped time and date portions of the DTA structure to
 RC> integers?  Thanks

Both the date and time are stored in DTA in 16 bits (integers). Here's
a couple of functions we use to convert the bit maps into strings:

FUNCTION FileDate$ (Date%) STATIC
    '--convert DOS file date to a date string
    '--date format MM-DD-YY

    UDate& = Date%
    IF UDate& < 0 THEN               'convert to unsigned integer
        UDate& = UDate& + 65536
    END IF

    Yr% = UDate& \ 512
    Mth% = (UDate& MOD 512) \ 32
    Dy% = UDate& - Yr% * 512 - Mth% * 32
    Yr% = Yr% + 1980

    FileDate$ = RIGHT$(STR$(Mth% + 100), 2) + "-" + _
            RIGHT$(STR$(100 + Dy%), 2) + "-" + RIGHT$(STR$(Yr%), 2)

END FUNCTION

FUNCTION FileTime$ (Time%) STATIC
    '--convert DOS file time to string
    '--time format HH:MM

    UTime& = Time%
    IF UTime& < 0 THEN                   'convert to unsigned integer
        UTime& = UTime& + 65536
    END IF
    Hr% = UTime& \ 2048
    Mnt% = (UTime& MOD 2048) \ 32

    FileTime$ = RIGHT$(STR$(100 + Hr%), 2) + ":" +_
             RIGHT$(STR$(100 + Mnt%), 2)

END FUNCTION

Good luck!

Tony

... Taglines are irrelevant. You will be assimilated into the Blue Wave.
--- Blue Wave/Max v2.10 [NR]
 * Origin: Oakland BBS - McDonough, GA - (404) 954-0071 (1:133/706.0)

ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
 Area:    QUIK BASIC
 Date:    04 Nov 92  08:44:08  Public
 From:    Jon Leger
 To:      Robert Church
 Subject: Re: File's date and time in DOS DTA
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
RC> How do I get the date and time from the Dos DTA?  I've got the DTA structu
RC> and the FindFirst/FindNext routines, but how do I convert the bit-mapped t
RC> and date portions of the DTA structure to integers?  Thanks
RC>
RC>     [-=ROB=-]

Use the GetFileData (dta, File as FileDataType) sub.

Example:
TYPE FileDataType
     FileName as string * 12
     FileYear as integer
     FileMonth as integer
     FileDay as integer
     FileHour as integer
     FileSecond as integer
     FileAttrib as integer
     FileSize as integer
END TYPE

'Ok. You wanna find the date and time for MYFILE.TXT
'This is what you do.

'First set MyFile as FileDataType
DIM MyFile as FileDataType
'Second get the file's data
FindFirstFile "MYFILE.TXT",d$,r%
'Ok, now that that is done, get the file's information
GetFileData d$,MyFile

'That would get you all of 'MYFILE.TXT's information. Now all you have to
'do is print that information.

COLOR 7: CLS
PRINT "File Name: "+MyFile.FileName
PRINT "File Date: "+MyFile.FileYear+"/"+MyFile.FileMonth+"/"+MyFile.FileDa
y
PRINT "File Time: "+MyFile.FileHour+":"+MyFile.FileMinute+":"+MyFile.FileS
econd
END

-----
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET