Cant get variable value from global class [OOP] Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
murataygun
Posts: 104
Joined: 07 Aug 2015, 15:53

Cant get variable value from global class [OOP]

27 Dec 2021, 18:12

Why i cant access the global 'Settings class's variable from another class?

I can access variable from "autorun section" but cant access inside the core class.

See the code please;

Code: Select all

Settings := new Settings_Class()

Core := new Core_Class()


MsgBox, % Settings.publicVar


class Core_Class {


    __New() {

        MsgBox, % Settings.publicVar

    }



}


class Settings_Class {


    publicVar := "SettingVar1"


}
I just want a class and acces its properties in everywhere. Like public function. Thank you.
User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: Cant get variable value from global class [OOP]  Topic is solved

27 Dec 2021, 19:56

To make it super-global:

Code: Select all

global Settings := new Settings_Class()

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], peter_ahk and 288 guests