fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Musing re "use of unassigned var" warning 25 Nov 2020 19:30 #16759

  • FFF's Avatar

  • FFF

  • Topic Author


  • Posts: 1069
  • Above warning i get for code like:
    LOCAL aFiles AS FileSystemInfo[]
    ...
    TRY
    	aFiles:= aDirs[i]:GetFileSystemInfos("*."+ cExtension) 
    CATCH
    	System.Environment.Exit(0)
    END TRY
    ...
    FOR j:=1 UPTO aFiles:Length
    ...
    
    AFAIU, aFiles CAN'T be used, if the assignment fails - the app will dissappear prior to using the var.

    Initializing aFiles further up would remove the warning, but would i really gain something?
    Regards
    Karl (X# 2.7; Xide 1.27; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    Musing re "use of unassigned var" warning 25 Nov 2020 20:55 #16760

  • robert's Avatar

  • robert


  • Posts: 2023
  • Karl,
    The compiler does not really know that System.Environment.Exit(0) will abort the app.
    I would assign NULL in the declaration to get rid of the warning:

    LOCAL aFiles := NULL AS FileSystemInfo[]

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1