Read RTF on API 2

This worked before API2

if FileName <> "" then
  dim f as FolderItem
  
  f = SpecialFolder.Resource("Files").child(FileName)
  if f.exists then
    declare function documentView lib "AppKit" selector "documentView" ( TextArea as integer ) as integer
    declare function readRTFDFromFile lib "AppKit" selector "readRTFDFromFile:" ( TextArea as integer, file as CFStringRef ) as boolean
    
    if readRTFDFromFile( documentView( TextArea1.handle ), f.nativePath ) = false then
      MessageBox "Sorry, but an error occured."
    end if
  end if
end if

Now :
helpWindow.ReadHelp, line 9
Parameter “TextArea” expects type Integer, but this is type Ptr.
if readRTFDFromFile( documentView( TextArea1.handle ), f.nativePath ) = false then

Changing TextArea to DesktopTextArea doesn’t work

1 Like

Found solution

declare function documentView lib "AppKit" selector "documentView" ( TextArea as Ptr ) as integer

This works again