Sign in to follow this  
Followers 0
c.haslam

Possible bug: Return True and Return "" in same function make code inoperative elsewhere

4 posts in this topic

I think I have found a bug in AutoIt 3.2.10.0: I coded an error in a function: it returns "" in one place and True in another:

CODE
Func ChooseaPic($nrow)

Local $filspc,$t,$fnam,$nrb

$filspc = FileOpenDialog("Load a Picture",$gDirSpec & "\","Images (*.jpg)",1) ; file must exist

If $filspc="" Then Return ""

$nrb = $ixbase + $nrow

$t = GUICtrlRead($lblPicFsAr[$nrow])

if $t<>"" Then

if MsgBox(4096+$MB_YESNO+$MB_ICONQUESTION,$scriptName,"Replace " & $t & " ?")<>$IDYES Then Return False

GUICtrlDelete($rowsAr[$nrb][$kID])

$rowsAr[$nrb][$kID] = 0

EndIf

$fnam = GetFnamFromFilspc($filspc)

$rowsAr[$nrb][$kFnam] = $fnam

Return True

EndFunc

FreeImage_Save() was not saving a DIB to a .bmp file.

When I changed Return "" to Return False, FeeImage_Save() worked.

Script code, some 600 lines of it, available on request.

...chris


...chris

Share this post


Link to post
Share on other sites



What is "FreeImage_Save"? What is the rationale behind returning an empty string over returning just false? What does "inoperative" mean in this context?

Global Const $FreeImage_Save = "_FreeImage_Save@16"

There is no rationale behind returning an empty string over returning False. As I wrote, this was a coding error. An earlier version returned either $filspc or "". I changed one but not the other.

In this context, "inoperative" means that the .bmp file was not created. The calling code:

if ChooseaPic($nrow) Then
        LoadaPic($nrow)
    EndIf

It took me a couple of hours to find the bug. @error was 0 in all cases.

...chris


...chris

Share this post


Link to post
Share on other sites

So... you're talking about a bug in your own code... that you already found... and you already fixed it? >_<

What was the point of this topic again?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0