Announcement

Collapse
No announcement yet.

initializing a QUAD

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • initializing a QUAD

    hi,

    i use the following code to initialize a QUAD

    Code:
        DIM s AS ASCIIZ * 9
        DIM q AS QUAD
        s = CHR$(255,0,255,0,255,0,255,0)
        MoveMemory BYVAL VARPTR(q), BYVAL VARPTR(s), 8
    i would better like to use

    q = &H00FF00FF00FF00FF

    but the HiDWORD in the Quad remains &H00000000
    is there any other solution ?

    regards,

    torsten


    ------------------

  • #2
    How about something like...

    Code:
    q = (dwHigh * (%MAXDWORD+1)) + dwLow
    I didn't try it, but you may be required to force the use of EXT math by using +1&& instead of just +1.

    -- Eric

    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>

    [This message has been edited by Eric Pearson (edited August 08, 2001).]
    "Not my circus, not my monkeys."

    Comment


    • #3
      Or, if you'd prefer to use strings...

      Code:
       DIM q AS QUAD
       q = CVQ(CHR$(255,0,255,0,255,0,255,0))
      -- Eric

      ------------------
      Perfect Sync Development Tools
      Perfect Sync Web Site
      Contact Us: mailto:[email protected][email protected]</A>

      [This message has been edited by Eric Pearson (edited August 08, 2001).]
      "Not my circus, not my monkeys."

      Comment


      • #4
        thank you eric

        ------------------

        Comment


        • #5
          Originally posted by Torte Torsten:
          i would better like to use
          q = &H00FF00FF00FF00FF
          but the HiDWORD in the Quad remains &H00000000
          It seems to work fine at my computer.
          What makes you think the HIDWORD remains 0?

          Regards, Theo

          ------------------

          Comment


          • #6
            hi theo,

            q = &H00FF00FF00FF00FF
            compiles, but leaves the HI_DWORD &H00000000,
            as i wrote in my first post in this thread.

            CVQ is doing the job.

            regards,

            torsten

            ------------------

            Comment


            • #7
              Code:
                #Compile Exe
                Function PbMain
                  Local q As Quad
                  '=================================
                  ReDim qq(1) As Long At VarPtr(q)
                  qq(0) = &H9ABCDEF0 ' Low
                  qq(1) = &H12345678 ' High
                  '=================================
                  
                  ' Demo hex
                  ReDim b(7) As Byte At VarPtr(q)
                  Local i As Long, t As String
                  For i = 7 To 0 Step -1
                     t = t + Hex$(b(i), 2)
                  Next
                  MsgBox t
                End Function
              ------------------
              E-MAIL: [email protected]

              Comment


              • #8
                thank you semen, that works too.

                ------------------

                Comment


                • #9
                  I get the same result by giving q it's value directly...

                  Code:
                  #COMPILE EXE
                  FUNCTION PBMAIN
                  LOCAL q AS QUAD
                  
                  q=&H123456789ABCDEF0
                  
                  ' Demo hex
                  REDIM b(7) AS BYTE AT VARPTR(q)
                  LOCAL i AS LONG, t AS STRING
                  FOR i = 7 TO 0 STEP -1
                     t = t + HEX$(b(i), 2)
                  NEXT
                  MSGBOX t
                  
                  END FUNCTION

                  ------------------

                  Comment


                  • #10
                    I agree, you can certainly assign a QUAD value directly. I am wondering if Torte was using HEX$ to look at the QUAD, because HEX$ can easily be overflowed by a QUAD integer giving the impression of "wrong" results.
                    Code:
                    ' PB/CC test code.  Change PRINT to MSGBOX for PB/DLL, etc
                    FUNCTION PBMAIN
                        DIM q AS QUAD
                        q = &H0FF00FF00FF00FF&& ' optional QUAD type specifier added
                        PRINT q
                        PRINT HEX$(q \ &H10000,8) & HEX$(q AND &HFFFF,8)
                        WAITKEY$
                    END FUNCTION
                    ------------------
                    Lance
                    PowerBASIC Support
                    mailto:[email protected][email protected]</A>
                    Lance
                    mailto:[email protected]

                    Comment


                    • #11
                      thx lance and all other,

                      you drove me the right direction.
                      direct assignment works, but i had to
                      reverse the byte order against the
                      CVQ Statement. what stupid mistake of me.
                      it's time for me for the next strong personal
                      service pack

                      regards,

                      torsten

                      ------------------

                      Comment

                      Working...
                      X