Announcement

Collapse
No announcement yet.

Inside DOS Powerbasic, copy to clipboard?

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

  • Inside DOS Powerbasic, copy to clipboard?

    Suppose Location$ = "Miami, Dade County, Florida"

    Can I copy or save that to the Windows Clipboard from PowerBasic DOS?

    Thank you. (Then my program will -almost- be finished!)

    Robert

  • #2
    Yes, it's done using registers stuff.
    Google.
    But maybe 'HAL' comes into play?

    You can also create a simple 32 bit app doing this for you?
    hellobasic

    Comment


    • #3
      Might help, might not (read disclaimer)
      http://www.powerbasic.com/support/pb...ad.php?t=40828

      If this does NOT work under Win32 and no one else has a function to do this, you* could always write a Windows program and shell it...
      Code:
      #COMPILE  WIN32EXE
      
      FUNCTION PBMAIN AS LONG 
      
         TheText =  COMMAND$ 
           or 
         TheText =  text of the file name passed as COMMAND$
         CLIPBOARD SET TEXT TheText 
      END FUNCTION
      CALL AS
      Code:
      $COMPILE MSDOS_EXE 
      
        TheText = Whatever
      
          SHELL   "aboveprogram  TheText"  
          or 
          CALL SaveTextToFile   (TheText, TheFile)
          SHELL   "aboveProgram  TheFile"
      MCM
      *or some other kind soul
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        I just looked again: Apparently I DID test it under Win/32... if you want to call Win/98 Win32.
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Tried it using Win/XP Pro SP3 this am.... did not report any errors, but did not work.

          It started with ENVIRON$() not finding the "windir" enviroment variable (even though it exists in my command shell) and went downhill from there.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Hi Robert.

            What you want can be done from inside your program.
            You need the Dracula PowerBASIC Tools.
            It is a set of tools in the form of PowerBASIC Units.
            You can use them as functions. There is support for the
            native Pbasic help system with many examples.
            The package consists of PBU files, INC files and Header files.
            First read about the way to use PBU files with PBasic and
            read the text files.

            I have used all of his tools in the past and solve a lot of problems
            with them.
            You find the files here: http://dracuul.tripod.com/pbdos/
            sigpic
            Regards,
            Hans Rietveld.

            Comment


            • #7
              Hi Robert

              Here's some code to copy from within PBDOS to the windows clipboard.

              Code:
              Declare Function GetStrLoc(ByVal AllocHandle%) As Long
               
              Function SetCBText(ByVal CBText As String) As Word
                ! push ax           ; save register states
                ! push bx
                ! push cx
                ! push dx
                ! push es
                ! push si
                ! mov ax, CBText    ; String handle into ax
                ! push ax           ; Pass it as a parameter
                ! call GetStrLoc    ; Call internal PB Function
                ! mov es, dx        ; DX contains the segment address of the string
                ! mov bx, ax        ; AX contains the offset address of the string
                ! mov si, 0         ; set SI to zero, CX already has our length
                ! mov ax, &H1703    ; Function 0x1703
                ! mov dx, 1         ; we're sending Text Data
                ! int &H2F          ; attempt to send the data to the clipboard
                ! mov SetCBText, ax ; return our result to the caller
                ! pop si            ; restore original register states
                ! pop es
                ! pop dx
                ! pop cx
                ! pop bx
                ! pop ax
              End Function
               
              SetCBText "Hello from PB-DOS!"
              End
              This also works in standard DOS running under VMWare. Can add to clipboard in Windows using the above code.
              Scott Slater
              Summit Computer Networks, Inc.
              www.summitcn.com

              Comment


              • #8
                Scott:
                Do you have the READ clipboard PBDOS function too? I'm sure that some readers (I'm one of them) would find it useful.

                Comment


                • #9
                  I should have looked at Michael's post. It includes a read function.
                  http://powerbasic.com/support/pbforu...ad.php?t=40828

                  Comment


                  • #10
                    If you plan on doing this under Win2K or better, you'll need to use this add-on.

                    http://www.phatcode.net/downloads.php?id=188
                    Scott Slater
                    Summit Computer Networks, Inc.
                    www.summitcn.com

                    Comment


                    • #11
                      I used this code for many years..

                      It was a collection from the original Powerbasic site in 1997.

                      This came out of a program I wrote to read a file onto the clipboard or dump the clipboard INTO a file:

                      Code:
                      FUNCTION OpenClipboard%
                      
                        'This function opens the Clipboard for your VM (Virtual
                        'Machine). Once you have opened the Clipboard, no other
                        'application can access it.  You must close the clipboard
                        'when you are finished, to allow other applications to
                        'access it.
                      local temp&
                      ASM     mov ax,&H1701   ;open clipboard
                      ASM     int &H2F
                      ASM     mov temp&,ax
                      
                      IF temp& THEN OpenClipboard% = %TRUE
                      
                      END FUNCTION
                      
                      FUNCTION SetClipboardData%(Text$)
                      local temp&, length%, pointr&, segmnt&
                      
                        IF LEN(Text$) THEN
                          length%=LEN(Text$)
                          IF ClearClipboard% = %TRUE THEN
                              pointr&=STRPTR(Text$):segmnt&=STRSEG(Text$)
                              temp&=0
                              IF ASMSetClipB%(pointr&,segmnt&,length%) THEN
                                  SetClipboardData% = %TRUE
                              END IF
                          END IF
                        END IF
                      END FUNCTION
                      
                      SUB CloseClipboard
                      
                        'This routine closes the Windows Clipboard. It is essential
                        'that your application closes the clipboard, or no other
                        'application can get access to it.
                      local temp&
                      ASM     mov ax,&H1708        ;Close Clipboard
                      ASM     int &H2f
                      ASM     mov temp&,ax
                      
                      END SUB
                      
                      FUNCTION GetClipboardData$
                      
                        'This routine gets the Windows clipboard text, and returns it
                        'in a string. The Clipboard must be opened first before it can
                        'be accessed.
                        'Before you can get the data, you must know how large the data
                        'is, to allocate space for it in a BASIC string.
                      '
                      local temp&, length%, pointr&, segmnt&
                      Length% = GetClipboardDataSize%
                      IF Length% > 0 THEN           'There is data, get it
                          Temp$ = STRING$(Length%, 0)  'Allocate the space in BASIC
                          pointr&=STRPTR(Temp$):segmnt&=STRSEG(Temp$)
                      '
                          IF ASMGetClipB% (pointr&, segmnt&) THEN             'If present it's null-terminated
                              Length% = INSTR(Temp$, CHR$(0))
                              IF Length% THEN            'Return with the data
                                  GetClipboardData$ = LEFT$(Temp$, Length%)
                              END IF
                          END IF
                      END IF
                      END FUNCTION
                      
                      FUNCTION GetClipboardDataSize%
                        'The clipboard stores text and graphics, so DX stores the data
                        'selector. 1 = Text, 2 = Graphics. The length of the data is
                        'returned in AX.
                      local temp&
                      
                      ASM     mov ax,&H1704       ;Get clipboard data size
                      ASM     mov dx,1            ;Request Text
                      ASM     int &H2f
                      ASM     mov temp&,ax
                      
                      GetClipboardDataSize% = temp& 
                      END FUNCTION
                      
                      FUNCTION ClearClipboard%
                      
                        'This Function returns %TRUE (-1) if the Clipboard was cleared.
                        'The clipboard must be opened first.
                      
                      local temp&
                      
                      ASM     mov ax,&H1702        ;Clear Clipboard
                      ASM     int &H2F
                      ASM     mov temp&[00],ax
                      
                      IF temp& THEN ClearClipboard% = %TRUE
                      
                      END FUNCTION
                      
                      FUNCTION ASMSetClipB% (BYVAL pointr&, BYVAL segmnt&, BYVAL length%)
                      ASM     mov ax,&H1703       ;Set clipboard data
                      ASM     mov dx,7            ;Data format is text
                      ASM     xor si,si
                      ASM     mov cx,length%
                      ASM     mov bx,pointr&
                      ASM     mov es,segmnt&
                      ASM     int &H2f
                      ASM     mov temp&,ax
                      If temp& then ASMSetClipB%=%TRUE
                      END FUNCTION
                      
                      FUNCTION ASMGetClipB% (BYVAL pointr&, BYVAL segmnt&)
                      ASM     mov ax,&H1705       ;Get clipboard data
                      ASM     mov dx,7            ;Data format is text
                      ASM     mov bx,pointr&
                      ASM     mov es,segmnt&
                      ASM     int &H2f
                      ASM     mov temp&,ax
                      If temp& then ASMGetClipB%=%TRUE
                      END FUNCTION
                      Scott Turchin
                      MCSE, MCP+I
                      http://www.tngbbs.com
                      ----------------------
                      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

                      Comment

                      Working...
                      X