Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
142 user(s) are online (137 user(s) are browsing Forums)

Members: 2
Guests: 140

Steady, nbache, more...

Support us!

Headlines

 
  Register To Post  

How put text file contents into the clipboard?
Home away from home
Home away from home


See User information
Can anyone tell me how to put the contents of a file (including new lines) into the clipboard of OS4?

We have the "clip" command, but that only seems to allow putting a single line of text into the clipboard.

There is a "clip" command (from 2001) on Aminet, which does what I want, but it mysteriously crashes when I try to call it from my own program (but not from the Shell) so I think it must be buggy.

We have a "CLIPS:" assignment, but copying stuff to it doesn't seem to do anything?

Author of the PortablE programming language.
Go to top
Re: How put text file contents into the clipboard?
Home away from home
Home away from home


See User information
From the AWeb source using IIFParse.library



void Clipcopy(UBYTE *text,long length)
{
struct IFFHandle *iff;
UBYTE *p;
for(p=text;p<text+length;p++)
{ if(*p==0xa0) *p=' ';
}
if(iff=AllocIFF())
{ if(iff->iff_Stream=(ULONG)OpenClipboard(PRIMARY_CLIP))
{ InitIFFasClip(iff);
if(!OpenIFF(iff,IFFF_WRITE))
{ if(PushChunk(iff,ID_FTXT,ID_FORM,IFFSIZE_UNKNOWN)) goto err;
if(PushChunk(iff,ID_FTXT,ID_CHRS,length)) goto err;
if(WriteChunkBytes(iff,text,length)!=length) goto err;
if(PopChunk(iff)) goto err;
if(PopChunk(iff)) goto err;

err:
CloseIFF(iff);
}
CloseClipboard((struct ClipboardHandle *)iff->iff_Stream);
}
FreeIFF(iff);
}
}

Go to top
Re: How put text file contents into the clipboard?
Home away from home
Home away from home


See User information
BTW The assingment CLIPS: is literaly an assignment so copying to it will copy a file to ram:clipboard




Go to top
Re: How put text file contents into the clipboard?
Just can't stay away
Just can't stay away


See User information
@ChrisH

Easiest way would be to use WriteClipVector() from textclip.library:
Quote:

ITextClip->WriteClipVector(string, strlen(string));

Go to top
Re: How put text file contents into the clipboard?
Home away from home
Home away from home


See User information
@salass00, broadblues
So there is really no easy solution that non-programmers can use?

It seems that I can read from TEXTCLIP: but not write to it (using C:Copy).

Author of the PortablE programming language.
Go to top
Re: How put text file contents into the clipboard?
Just can't stay away
Just can't stay away


See User information
I thought that was what you were asking for, an easy solution for a programmer, since you said that:
Quote:

There is a "clip" command (from 2001) on Aminet, which does what I want, but it mysteriously crashes when I try to call it from my own program (but not from the Shell) so I think it must be buggy.

Go to top
Re: How put text file contents into the clipboard?
Home away from home
Home away from home


See User information
@salass00
Well, an easy solution for non-programers would also be a (very!) easy solution for programmers

I'm just surprised what I want to do isn't actually possible, without using a compiled programming language.

Author of the PortablE programming language.
Go to top
Re: How put text file contents into the clipboard?
Just popping in
Just popping in


See User information
put the output stream to textclip like:


type ram:test.txt > textclip:

Go to top
Re: How put text file contents into the clipboard?
Amigans Defender
Amigans Defender


See User information
@salass00

Quote:
Easiest way would be to use WriteClipVector() from textclip.library

Out of curiosity: as I haven't found textclip.library anywhere in the system, where is it located actually? Is it part of some other OS component?

The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: How put text file contents into the clipboard?
Home away from home
Home away from home


See User information
@Goos
That worked, thanks!

Author of the PortablE programming language.
Go to top
Re: How put text file contents into the clipboard?
Just can't stay away
Just can't stay away


See User information
@ChrisH
Quote:
I'm just surprised what I want to do isn't actually possible, without using a compiled programming language.

Well in OS3.9, there was not even a Clip command One step at a time

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: How put text file contents into the clipboard?
Just can't stay away
Just can't stay away


See User information
@trixie
Quote:

Out of curiosity: as I haven't found textclip.library anywhere in the system, where is it located actually? Is it part of some other OS component?


Looks like it might be generated in memory by textclip-handler:
Resized Image
http://dl.dropbox.com/u/26599983/textclip_library.jpg

Go to top
Re: How put text file contents into the clipboard?
Just can't stay away
Just can't stay away


See User information
Quote:
Goos wrote:
put the output stream to textclip like:


type ram:test.txt > textclip:
Hey, brilliant! Another little known Amiga gem revealed. Thanks!

Best regards,

Niels

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project