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

Andrew Stephenson

  • Newbie
  • *
  • Posts: 47
  • 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: 4605
  • Karma: +92/-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: 614
  • 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

Andrew Stephenson

  • Newbie
  • *
  • Posts: 47
  • Karma: +1/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #3 on: November 14, 2023, 02:33:33 pm »
Thank you, Dave and Roderick.  I plan to use Open Watcom salvaged from my very dead eCS system.   OW version date/number not available now, as I just received my new m/c and have yet to reinstate personal software, but at least 5-6 years old.  I'm wondering about updating anyhow.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4605
  • Karma: +92/-1
    • View Profile

Andrew Stephenson

  • Newbie
  • *
  • Posts: 47
  • Karma: +1/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #5 on: November 14, 2023, 05:02:35 pm »
Latest OpenWatcom, ftp://ftp.netlabs.org/pub/openwatcom/open-watcom-c-os2-2.0-beta-4.exe
Ta muchly.  I'll have to get to it when my AOS-5.1 m/c is fully functional.

BTW, I followed up Roderick's URL and found myself wondering where 'C' programmers get their info on OS/2's clipboard.  It can't be sources on 'C', such as "libc" which I dutifully dug through, because IIRC the 'C' Language doesn't concern itself with I/O -- that's set by users.  Is there, say, a wiki?

Andy Willis

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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4482
  • 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 #7 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: 769
  • Karma: +65/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #8 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: 270
  • Karma: +21/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #9 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: 175
  • Karma: +4/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #10 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)

Andrew Stephenson

  • Newbie
  • *
  • Posts: 47
  • Karma: +1/-0
    • View Profile
Re: Copying text strings to AOS-5.1 clipboard in 'C'
« Reply #11 on: November 16, 2023, 01:13:16 pm »
Thanks for all the inputs, folkses.  Sorry to be slow in replying but things got a little crazy here: my new M900 m/c + AOS-5.1 was on my desk, being sniffed at cautiously but with admiration, when the mouse decided to stop moving the pointer.  After some ten years it decides to quit after a brief exposure to AOS.  Frustrating.  (And I'm back on the Windows-10-infested Dell.)  However, in my experience, RTFM -- Ranting To Fix Misadventures -- doesn't always work, so one step at a time.

Anyhow, to address points...

(Re: the edm2.com site)  Yes, I already found those pages, thanks, but maybe missed the part(s) with the formal skinny on using clipboard functions.  Must take another look, RSN (Real Soon Now).

(Re: Martin)  Yes, I even read github.  As to sharing code, I don't object but until my system gets re-moused and working again the app I have in mind is just that, in my mind.  As to drifting off the subject: be my guest; it enlivens the scenery.

(Re: Rich && "Presentation Manager Programming Guide and Reference")  Ta. I have it but must delay reading until AOS can help, Windows 10 being (seemingly) clueless -- unless I'm being c/less.

And so to the computer store.  Then (maybe) bed.