简体   繁体   English

Windows的Turbo Pascal:将输出复制到剪贴板吗?

[英]Turbo Pascal for Windows: Copy output to clipboard?

I'm completing a program in Turbo Pascal 7 for Windows as part of a programming class school project, essentially we've been given a brief and told to go off by ourselves and implement and code the program. 作为编程课程学校项目的一部分,我正在Windows Turbo Pascal 7中完成一个程序,从本质上讲,我们已经得到了简短的介绍,并告诉我们自己去实施和编码程序。

The brief states to create a program where a user can enter a message, select a letter shift, and then each letter will be 'encrypted' according to that shift (essentially ROT13). 该摘要说明创建了一个程序,用户可以在该程序中输入消息,选择一个字母移位,然后根据该移位(基本上是ROT13)对每个字母进行“加密”。 Easy. 简单。

I've got in running in the Turbo Pascal for Windows 7 terminal window, and it outputs the resulting encrypted text: 我已经在Windows 7的Turbo Pascal终端窗口中运行了,它会输出生成的加密文本:

writeln('Encrypted message is ', line ,' for a shift of ', shift);
readln;

What I'd like to do is extend beyond this by going one step further and allow the user to copy the output (var: line) to their windows clipboard. 我想做的就是进一步扩展此功能,并允许用户将输出(var:行)复制到他们的Windows剪贴板中。 I've been searching far and wide across the internet for two days now and have yet to come across anything which can help me. 我已经在互联网上搜索了两天,但还没有发现任何可以帮助我的东西。 I'm now starting to wonder if Pascal even has the ability to do this? 我现在开始怀疑Pascal是否有能力做到这一点?

Cheers, Luke. 干杯,卢克。

I'm now starting to wonder if Pascal even has the ability to do this? 我现在开始怀疑Pascal是否有能力做到这一点?

Yes if you don't use that outdated 20 years old Pascal product. 是的,如果您不使用过时的Pascal产品已有20年历史。 I'm not sure whether it can access the clipboard (since windows clipboard is 32-bit API) or not, but big chance it can't, at least not without hack. 我不确定它是否可以访问剪贴板(因为Windows剪贴板是32位API),但是它很有可能不能访问,至少没有黑客。 Use Free Pascal or Delphi and access Windows API directly to play with clipboard (search MSDN for this). 使用Free Pascal或Delphi并直接访问Windows API来玩剪贴板(为此搜索MSDN)。

PS: Clipboard has nothing to do with Pascal as a language. PS:剪贴板与Pascal语言无关。 It's simply a concept that the OS has, and it allows programs to use it. 这只是操作系统所具有的一个概念,它允许程序使用它。

First, is the resulting binary a DOS or win3.x EXE? 首先,生成的二进制文件是DOS还是win3.x EXE?

If DOS Afaik there are ways to reach the clipboard from dos via INT 2F extensions. 如果是DOS Afaik,则可以通过INT 2F扩展名从dos到达剪贴板。

Search in the massive SWAG archive that contains heaps of examples for Turbo Pascal (and -For Windows) 在大量的SWAG档案中搜索,其中包含Turbo Pascal(和-对于Windows)的大量示例

If win3x then 如果是win3x

http://www.programmersheaven.com/mb/pasprog/420895/420895/use-of-windows-clipboard/ http://www.programmersheaven.com/mb/pasprog/420895/420895/use-of-windows-clipboard/

If this reply sounds very vague, then it is because all this is 20 years ago :-) 如果这个答复听起来很含糊,那是因为这一切都在20年前:-)

If you were using Delphi, you could use Clipboard.SetTextBuf(PChar(somestring)); 如果使用的是Delphi,则可以使用Clipboard.SetTextBuf(PChar(somestring));。 This is how I do it in my Dos2Clip utility, which apparently I made available free back in 2005. I've made the source available at the link below, all 25 lines of it. 这就是我在Dos2Clip实用程序中执行的操作,该实用程序显然是在2005年免费提供的。我在下面的链接中提供了该源代码,其中包括25行。 ;) ;)

In Vista and higher, there is a "clip" command available in batch files or the command line. 在Vista和更高版本中,批处理文件或命令行中提供了一个“剪辑”命令。

ex: echo “hello, world!” | 例如:回声“你好,世界!” | clip

See my writeup here, which has a download link for my Dos2Clip program (with source). 在这里查看我的文章,其中包含我的Dos2Clip程序的下载链接(带有源代码)。 I see Clip2Dos is in there too. 我也看到了Clip2Dos。

http://www.clipboardextender.com/general-clipboard-use/command-window-output-to-clipboard-in-vista http://www.clipboardextender.com/general-clipboard-use/command-window-output-to-clipboard-in-vista

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM