Author Topic: Copying text strings to AOS-5.1 clipboard in 'C'  (Read 4665 times)

Andrew Stephenson

  • Newbie
  • *
  • Posts: 20
  • Karma: +1/-0
    • View Profile
Copying text strings to AOS-5.1 clipboard in 'C'
« 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.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4761
  • Karma: +98/-1
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #1 on: November 13, 2023, 04:24:52 pm »
What compiler? GCC at least would just use putenv()

Roderick Klein

  • Hero Member
  • *****
  • Posts: 652
  • Karma: +14/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #2 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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4761
  • Karma: +98/-1
    • View Profile

Andy Willis

  • Sr. Member
  • ****
  • Posts: 290
  • Karma: +7/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #4 on: November 15, 2023, 02:28:10 am »

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4677
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #5 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) ", but it is too long to read.

Maybe you can check the OS2World Github 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
« Last Edit: November 15, 2023, 03:44:08 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

David Graser

  • Hero Member
  • *****
  • Posts: 862
  • Karma: +83/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #6 on: November 15, 2023, 09:58:40 pm »
I am no programmer. this site contains all the API info.

http://www.edm2.com/os2api/

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 319
  • Karma: +22/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #7 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>

Tom

  • Full Member
  • ***
  • Posts: 189
  • Karma: +5/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #8 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)