You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
PowerBASIC and related source code. Please do not post questions or discussions, just source code.
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
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/
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.
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
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment