Jump to content

Variables problem


Recommended Posts

Hey, i keep on getting errors that variable was used before declared or some other weird stuff. It doesn't realy matter if i have the function executed or not. Hope someone can find what's wrong here :)Tnx

microsoft_office_check()

Func microsoft_office_check(); Response: $Office_Version = XP/2003/NOPE, $Project_Version = NOPE/2003, $Visio_Version = NOPE/2003
    Local $Office_XPPL = ""
    Local $Office_XPPL_reg = ""
    Local $Office_2003PL = "1111-1111-11111"
    Local $Office_2003PL_reg = "{90110415-6000-11D3-8CFE-0150048383C9}"
    Local $Office_2003ENG = "1111-1111-11111"
    Local $Office_2003ENG_reg = "{90110409-6000-11D3-8CFE-0150048383C9}"
    Local $Project2003PL = "1111-1111-111113"
    Local $Project2003PL_reg = "{903B0415-6000-11D3-8CFE-0150048383C9}"
    Local $Project2003ENG = "1111-1111-11111"
    Local $Project2003ENG_reg = "{903B0409-6000-11D3-8CFE-0150048383C9}"
    Local $Visio2003PL = "1111-1111-11111"
    Local $Visio2003PL_reg = "{90510415-6000-11D3-8CFE-0150048383C9}"
    Local $Visio2003ENG = "1111-1111-11111"
    Local $Visio2003ENG_reg = "{90510409-6000-11D3-8CFE-0150048383C9}"
    
    $Reg_Office_XPPL = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\10.0\Registration\" & $Office_XPPL_reg, "ProductID")
    $Reg_Office_2003PL = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\" & $Office_2003PL_reg, "ProductID")
    $Reg_Office_2003ENG = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\" & $Office_2003ENG_reg, "ProductID")
    $Reg_Project_2003PL = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\" & $Project_2003PL_reg, "ProductID")
    $Reg_Project_2003ENG = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\" & $Project_2003ENG_reg, "ProductID")
    $Reg_Visio_2003PL = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\" & $Visio_2003PL_reg, "ProductID")
    $Reg_Visio_2003ENG = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\" & $Visio_2003ENG_reg, "ProductID")

; CHECKS
    Global $Office_Version = "NOPE", $Project_Version = "NOPE", $Visio_Version = "NOPE"
    Global $Office_Language = "NOPE", $Project_Language = "NOPE", $Visio_Language = "NOPE"
; Office XP PL Check
    If $Reg_Office_XPPL = $Office_XPPL AND FileExists(@ProgramFilesDir & "\Microsoft Office\OFFICE10\WINWORD.EXE") Then
        $Office_Version = "XP"
        $Office_Language = "PL"
    EndIf
; Office 2003 ENG Check
    If $Reg_Office_2003ENG = $Office_2003ENG AND FileExists(@ProgramFilesDir & "\Microsoft Office\OFFICE11\WINWORD.EXE") Then
        $Office_Version = "2003"
        $Office_Language = "ENG"
    EndIf
; Office 2003 PL Check
    If $Reg_Office_2003PL = $Office_2003PL AND FileExists(@ProgramFilesDir & "\Microsoft Office\OFFICE11\WINWORD.EXE") Then
        $Office_Version = "2003"
        $Office_Language = "PL"
    EndIf   
; Project 2003 ENG Check
    If $Reg_Project_2003ENG = $Project_2003ENG AND FileExists(@ProgramFilesDir & "\Microsoft Office\OFFICE11\WINPROJ.EXE") Then
        $Project_Version = "2003"
        $Project_Language = "ENG"
    EndIf
; Project 2003 PL Check
    If $Reg_Project_2003PL = $Project_2003PL AND FileExists(@ProgramFilesDir & "\Microsoft Office\OFFICE11\WINPROJ.EXE") Then
        $Project_Version = "2003"
        $Project_Language = "PL"
    EndIf
; Visio 2003 ENG Check
    If $Reg_Visio_2003ENG = $Visio_2003ENG AND FileExists(@ProgramFilesDir & "\Microsoft Office\VISIO11\VISIO.EXE")  Then
        $Visio_Version = "2003"
        $Visio_Version = "ENG"
    EndIf
   ; Visio 2003 PL Check    
    If $Reg_Visio_2003PL = $Visio_2003PL AND FileExists(@ProgramFilesDir & "\Microsoft Office\VISIO11\VISIO.EXE")  Then
        $Visio_Version = "2003"
        $Visio_Language = "PL"
    EndIf

EndFunc

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

Is this not a good time to introduce:

Opt("MustDeclareVars", 1)

?

I suppose you could, but I haven't ever used it. I like being able to declare vars on the fly. Plus, others may not have used that option when they wrote their script (for example, IE.au3), and using that in accordance with the #included script will cause a lot of errors, and a lot of unnecessary time fixing the var problems. So I just leave it out (I've never even considered it.. in fact, I avoid it).
Link to comment
Share on other sites

  • Moderators

I suppose you could, but I haven't ever used it. I like being able to declare vars on the fly. Plus, others may not have used that option when they wrote their script (for example, IE.au3), and using that in accordance with the #included script will cause a lot of errors, and a lot of unnecessary time fixing the var problems. So I just leave it out (I've never even considered it.. in fact, I avoid it).

I've not used it either..., I declare them anyway with = '' if necessary by habbit.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...