Modify

#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 Changed 12 months ago by Jpm

  • Resolution set to No Bug
  • Status changed from new to closed

@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

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.