Exception at blob.CopyString

what I am doing ? I am reading an image, making a copy and shrinking the copy to a thumbnail

on my Mac 10.11 this this works
on my other Mac 10.15 it gets an exception
exception line is : b.Write blob.CopyString.
The exception I get is here

here is the code.

Please advise …

const UndefinedFilter=0
const PointFilter=1
const BoxFilter=2
const TriangleFilter=3
const HermiteFilter=4
const HanningFilter=5
const HammingFilter=6
const BlackmanFilter=7
const GaussianFilter=8
const QuadraticFilter=9
const CubicFilter=10
const CatromFilter=11
const MitchellFilter=12
const LanczosFilter=13
const BesselFilter=14
const SincFilter=15

Dim t As FolderItem

// original image
if not SourceFolder.Child(oldName).Exists or SourceFolder = Nil then
  MsgBox "Source Does Not Exist " + SourceFolder.Child(oldName).NativePath
  Return False
end if

// Destination Folder
if not DestinationFolder.Exists or DestinationFolder = Nil then
  MsgBox "Thumbnail or Destination folder does not exisit " + DestinationFolder.NativePath
  Return False
end if

dim image as new GM16ImageMBS
image.read(SourceFolder.Child(oldName))

image.filterType = image.LanczosFilter
image.scale(new GM16GeometryMBS(size, size))

// save 16 bit
dim blob as new GM16BlobMBS
image.depth = 16
image.write blob

t = DestinationFolder.Child(newName)
dim b as BinaryStream
b = t.CreateBinaryFile("application/binary")
b.Write blob.CopyString
b.Close

Return True

You’re getting a NilObjectException because b is Nil. I can’t find any documentation for the FolderItem.CreateBinaryFile method but the compiler seems to accept it. Presumably it was deprecated a long, long time ago. Try using BinaryStream.Create instead:

t = DestinationFolder.Child(newName)
dim b as BinaryStream
b = BinaryStream.Create(t)
b.Write blob.CopyString
t = DestinationFolder.Child(newName)
dim b as BinaryStream = BinaryStream.Create(t)
if b = nil then 
    messagedialog "error message here"
    return
end if
try
   b.Write blob.CopyString
catch
    messagedialog "macos freaked out"
    return
end try

For bonus points try using property names that make more sense.

1 Like

Yup, have this in my apps too! Lol!

Hello Andrew,
but will this code work with 2019 1.1r
I am scared to death to upgrade past 2019 as i tried it and all my apps ceased to work

BinaryStream.Create has been around since the Realstudio days.

Why should this happen? The old code is deprecated but it works fine.

all i know is when i tried upgrading above 2019 1.1r
simple things like sockets failed to work.
listboxes had issues with re-ordering and refreshing.
and maybe a dozen other issues.