Bad times never go away

The code below is weird:

  If Source_Height > MinSize Then
    If Source_Width > Source_Height Then
      Scale_Factor = Source_Width / MinSize // '/': floating point division
    Else
      Scale_Factor = Source_Height / MinSize // '/': floating point division
    End If
  End If

In the debugger, the code runs until the first If line, then go directly to End Function and do not even return anything (a Picture, resized was meant to be returned).

MinSize was 200
Source_Height was 250

I got that fo years and ask y hair for my reaction.

Can you guess how many times I wasted before I discovers that ?

My doctor asks me if I am stressed, what can I say to her?
Yes, my blood pressure is high, yeah!

No later than yesterday, I got strange data Pasted from the Clipboard in a ListBox. Wrost: when I read my Clipboard contents, some parts of the pasted data comes from elsewhere because they are not in the Clipboard. The first line meant to be the Heading was wrong :frowning:

Also I have a TabPanel wth two panels, the Canvas from Tab1 appears below everything in Tab2.

Internet was off, only Xojo was running. Oh, I know, blame Apple ! ts MacBook Pro dislike working so late at night.

I’m not angry (though), I’m bitter.

there is no time for fixing problems, Android is more importend, can’t see why !!!

You do understand that we’re not all working on Android, right?

4 Likes

Are you asking why you forgot to use ELSE?

If Source_Height > MinSize Then
    If Source_Width > Source_Height Then
      Scale_Factor = Source_Width / MinSize // '/': floating point division
    Else
      Scale_Factor = Source_Height / MinSize // '/': floating point division
    End If
ELSE
        '  do something else
  End If

he wrote
MinSize was 200
Source_Height was 250

but to be sure add system.debuglog’s in this case is very helpful.

Nothing wrong with those values, apart from the situation that Scale_Factor is then not set.
So if Scale_Factor was left as zero, and it was used to scale a picture, probably boom.

To me , it needed

else
Scale_Factor = 1
end if

as a bare minimum

2 Likes

Alternatively, a post fix.

Scale_Factor = 1
If Source_Height > MinSize Then
    If Source_Width > Source_Height Then
      Scale_Factor = Source_Width / MinSize // '/': floating point division
    Else
      Scale_Factor = Source_Height / MinSize // '/': floating point division
    End If
End If
2 Likes

Yes. Sorry.

I let some good two days roll and go back to it to discover that I was walking beside my shoes that day. Tired, very tired (Ich bin müde.)

I didn’t set my mind on 200 or 250 !

That is clear now.