Modify

Opened 5 years ago

Closed 5 years ago

#3799 closed Bug (No Bug)

_ChooseFont (Canceling the dialog) suggestion.

Reported by: Dan_555 Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.0 Severity: None
Keywords: Cc:

Description

Currently, when the _ChooseFont is called, and the font dialog is cancelled, the array is not created and @error is not set for it.

Testcode fails, if the fontdialog is cancelled, at the $font=$aF[2]:

Func SelFont()						;Select a font
	Local $aF = _ChooseFont($font)
	If @error > 0 Then
		$font = "System2"
	Else		
			$font = $aF[2]		
	EndIf

EndFunc   ;==>SelFont

My Suggestion would be to set the @error flag to a number higher than 0

There is a workaround code, to check if the array was created:

Func SelFont()						;Select a font
	Local $aF = _ChooseFont($font)
	If @error > 0 Then
		$font = "System2"
	Else
		if IsArray($af) then
			$font = $aF[2]
		Else
			$font = "System2"
		EndIf
	EndIf

EndFunc   ;==>SelFont


Attachments (0)

Change History (1)

comment:1 by J-Paul Mesnage, 5 years ago

Resolution: No Bug
Status: newclosed

@error not zero should be checked

#include <Misc.au3>

Local $sFont = SelFont()
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sFont = ' & $sFont & @CRLF & '>Error code: ' & @error & '    Extended code: ' & @extended & ' (0x' & Hex(@extended) & ')' & @CRLF) ;### Debug Console

Func SelFont()						;Select a font
	Local $font
	Local $aF = _ChooseFont()
	If @error <> 0 Then
		$font = "System2"
	Else
		$font = $aF[2]
	EndIf

	Return $font
EndFunc   ;==>SelFont

Modify Ticket

Action
as closed The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.