I have created some nice GUI using AWNPipe for window, menu, toolbar buttons, and text display.
Now, I want to use AWNPipe text editor function to actually edit an existing text file and then save the file after the changes.
I have figured out how to create the texteditor gadget and how to display the file. As I type, the new text shows up in the display, but I can't figure out how to actually save the file.
I am assuming that AWNPipe uses the Reaction texteditor.gadget.
Any help would be appreciated.
---- redfox
BTW, this was very easy to do with RxMUI and the MUI texteditor gadet. The MUI texteditor gadget has an open file command and a save file command. Easy, peesy.
Edited by redfox on 2025/9/11 18:41:23 Edited by redfox on 2025/9/11 18:43:51 Edited by redfox on 2025/9/11 18:45:00 Edited by redfox on 2025/9/13 4:05:12 Edited by redfox on 2025/9/13 4:05:42 Edited by redfox on 2025/9/17 19:03:33
was supposed to mark the text from start of file to end of file, then copy the text to the clipboard.
After alot of trial and error, today I got the COPY command to work, but I have to manually highlight the the text with the mouse. I can't get the other commands to work. I just get a "received ok" response from the texteditor gadget.
The following ARexx command seems to copy the highlighted text to the clipboard.
call topipe('ID 'TE' command="COPY"')
ID 'TE' is a variable name for my texteditor gadget.
However, when I try to copy from the clipboard to a text file, the text has a filetype header imbedded in the first line.
FORM2FTXTCHRS&
Again ... rather than reinvent the wheel, I decided to just use NotePad instead. I can prefill text into the textfile, edit with NotePad if I need to make changes, save the file and move on. It is easy to launch NotePad using an ARexx script.
Used ARexx delete string command to delete those extra characters in the clipboard file. There must have been some nonprintable characters, because I could see 14 but had to delete 20.
Now working fine without NotePad. Please note, my program is not a replacement for NotePad or any other editor. This is simply a learning exercise to get more experience tinkering with ARexx and AWNPipe. I still have alot of debug code, but it works now.
I must highlight all the text in the editor window. I use the COPY function to copy from editor to clipboard, then I "save" the text back to the original text file by using ARexx readln and writeln commands to copy from clipboard to text file.
Cheers, redfox
Edited by redfox on 2025/9/13 4:04:12 Edited by redfox on 2025/9/13 4:08:55
However, when I try to copy from the clipboard to a text file, the text has a filetype header imbedded in the first line.
FORM2FTXTCHRS&
Again ... rather than reinvent the wheel, I decided to just use NotePad instead. I can prefill text into the textfile, edit with NotePad if I need to make changes, save the file and move on. It is easy to launch NotePad using an ARexx script.
Used ARexx delete string command to delete those extra characters in the clipboard file. There must have been some nonprintable characters, because I could see 14 but had to delete 20.
Everything in the AmigaOS clipboard is based on the ElectronicArts IFF format, extended by Commodore, and later adopted by Apple ("AIFF") and MicroSoft ("RIFF", wrong endian version of IFF) as well. It's always IFF, no matter if text, audio, graphics, video or something else. Even the most simple content: Text. "FORM" (IFF identifier) + 32 bit length of the complete data + "FTXT" (formatted text IFF sub-id) + 32 bit length of the "FTXT" part + "CHRS" (identifier for the actual data) = 4 ("FROM") + 4 (size) + 4 ("FTXT") + 4 (sub size) + 4 ("CHRS") = 20 bytes minimum header. There are other, optional, IFF chunks/sub-headers for FTXT like "FONS" (the font to be used), and at least since AmigaOS 4.x one for the charset (ISO-8859-15, UTF-8, etc.) of the "CHRS" content, check for example https://wiki.amigaos.net/wiki/FTXT_IFF_Formatted_Text
In any case you should use the IFF parsing rules, instead of simply removing the first 20 bytes. There are IFF libraries with ARexx interface for parsing, reading and writing IFF data, both for clipboard and files.
I am not a programmer by profession and I do not have whatever programming books you guys use for programming Amiga applications. I searched through whatever old OS4SDK documents that I could find and they were way beyond my level of comprehension.
In the end, I rediscovered an old friend named rexxtricks.library which contains many functions, including some Clipboard functions.
* READCLIPBOARD() ... Read text from clipboard
This function safely removed the IFF info.
-------
My other choice is to use NotePad to edit and save the file. In this case, I don't care about what is in the clipboard.
-------
By the way, I wrote two similar programs awhile ago. One uses RxMUI and the other uses ProAction.
I wanted to see if I could duplicate these programs using AWNPipe.