OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: Andrew Stephenson on November 13, 2023, 09:44:57 am

Title: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: Andrew Stephenson on November 13, 2023, 09:44:57 am
While waiting for my new m/c && AOS-5.1 to arrive, I've been keeping my brain busy outlining an app which, if it works nicely, I'd like to offer to the AN Free Fun Stuff section.  May I keep its nature vague for now?  I'm hoping someone can show me some simple 'C' code that copies text to the AOS (5.1, if it matters) clipboard.  I admit to being lazy but I do want to get it right (and safe) and researches suggest clipboard interfacing can be a can of worms.

Essentially, my app supplies char *pText where the string pointed to can be up to 200 chars (plus final \0) long.  If commanded, the app generates the string and copies it; otherwise, the string is only displayed on screen, allowing it to be redirected or piped in the usual way.

Maybe this has been asked before.  I did look but maybe in too much haste.
Title: Re: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: Dave Yeo on November 13, 2023, 04:24:52 pm
What compiler? GCC at least would just use putenv()
Title: Re: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: Roderick Klein on November 13, 2023, 04:53:00 pm
While waiting for my new m/c && AOS-5.1 to arrive, I've been keeping my brain busy outlining an app which, if it works nicely, I'd like to offer to the AN Free Fun Stuff section.  May I keep its nature vague for now?  I'm hoping someone can show me some simple 'C' code that copies text to the AOS (5.1, if it matters) clipboard.  I admit to being lazy but I do want to get it right (and safe) and researches suggest clipboard interfacing can be a can of worms.

Essentially, my app supplies char *pText where the string pointed to can be up to 200 chars (plus final \0) long.  If commanded, the app generates the string and copies it; otherwise, the string is only displayed on screen, allowing it to be redirected or piped in the usual way.

Maybe this has been asked before.  I did look but maybe in too much haste.

If you are writing a program with Open Watcom or Visual Age: try one of the following programs:
http://www.altsan.org/programming/os2/index.html#dbcsmap
Sources included.

Roderick
Title: Re: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: Dave Yeo on November 14, 2023, 04:22:34 pm
Latest OpenWatcom, ftp://ftp.netlabs.org/pub/openwatcom/open-watcom-c-os2-2.0-beta-4.exe (http://ftp://ftp.netlabs.org/pub/openwatcom/open-watcom-c-os2-2.0-beta-4.exe)
Title: Re: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: Andy Willis on November 15, 2023, 02:28:10 am
Here is a good place to start:
http://www.edm2.com/index.php/The_OS/2_API_Project

In particular, here are some clipboard info:
http://www.edm2.com/index.php/Programming_for_the_OS/2_PM_in_C:The_Clipboard
Title: Re: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: Martin Iturbide on November 15, 2023, 03:42:26 pm
Hello Andrew

I'm not a developer, but I tried to compile some little Presentation Manager (PM - our GUI) samples with gcc, just for my personal learning.
The community helped me on this forum thread. "Compiling a PM sample with GCC (2023) (https://www.os2world.com/forum/index.php/topic,3324.0.html) ", but it is too long to read.

Maybe you can check the OS2World Github (https://github.com/orgs/OS2World/repositories?q=DEV-SAMPLES-PM&type=all&language=&sort=) repository (filtered by the PM Samples) and check some samples there to help your learning. I included also a screenshot on the samples I was able to compile (with the help of the people here).  I didn't used OpenWatcom (it is on my wishlist to learn that), I just used make, gcc and other open source tools.

If you want to develop something, and don't mind sharing the source code, I would recommend you to post here your sample and what error/stopper you get, and see if we can help.

Sorry If I drift too much of the subject.

Regards
Title: Re: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: David Graser on November 15, 2023, 09:58:40 pm
I am no programmer. this site contains all the API info.

http://www.edm2.com/os2api/
Title: Re: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: Rich Walsh on November 15, 2023, 11:20:00 pm
With all due respect to others who have responded, I have to say that the only way you'll really know how things work is if you RTFM (a term, BTW, that had a long history on Usenet and was NEVER taken to be offensive).

To that end, I've attached the complete "Presentation Manager Programming Guide and Reference". Unzip it somewhere convenient then create a program object for it like so:

File name:     VIEW.EXE
Parameters:  pm1.inf+pm2.inf+pm3.inf+pm4.inf+pm5.inf
Working dir:  <directory containing these files>
Title: Re: Copying text strings to AOS-5.1 clipboard in 'C'
Post by: Tom on November 16, 2023, 01:27:53 am
With all due respect to others who have responded, I have to say that the only way you'll really know how things work is if you RTFM (a term, BTW, that had a long history on Usenet and was NEVER taken to be offensive).

You mean Read The Fine Manual? (eg,d&rfc)