Alpha Video Training
Results 1 to 3 of 3

Thread: How to call base class functions?

  1. #1
    Member
    Real Name
    Nate Marler
    Join Date
    Apr 2018
    Posts
    17

    Default How to call base class functions?

    Hi All - I need some syntax help. Specifically, how do I call base class functions from a derived class? If it's in the doc, I've missed it. Below I've tried some other ways that aren't working.

    Thanks

    Code:
    define class MyBaseClass
      function func1 as C()
      	debug(1)
      	return "MyBaseClass.func1"
      end function
    
      function func2 as C()
      	debug(1)
      	return "MyBaseClass.func2"
      end function
    end class
    
    
    define class MyClass inherits MyBaseClass
      function func1 as C()
      	debug(1)
        ' how call base class version of func1 from here?
        ' return func1() 'recursive call
        ' return base.func1() 'throws: "Not found base not found."
        ' return parent.func1() 'throws: "Not found parent not found."
        ' return MyBaseClass.func1() 'throws: "Not found MyBaseClass not found."
        ' return MyBaseClass::func1() 'throws: "Property not found"
      end function
    
      function func3 as C()
      	debug(1)
        ' How call func2 from here?
        ' return func2() 'throws error "Function: 'func2' was not recognized"
      end function
    end class

  2. #2
    Member Corelius's Avatar
    Real Name
    Cornelius Koempel
    Join Date
    May 2005
    Location
    Germany, Duisburg
    Posts
    176

    Default Re: How to call base class functions?

    Code:
    define class MyBaseClass
      function func1 as C()
      	debug(1)
      	return "MyBaseClass.func1"
      end function
    
      function func2 as C()
      	debug(1)
      	return "MyBaseClass.func2"
      end function
    end class
    
    
    define class MyClass inherits MyBaseClass
      function func1 as C()
      	debug(1)
      	dim mbc as MyBaseClass
      	msgbox(mbc.func1())
        ' how call base class version of func1 from here?
        ' return func1() 'recursive call
        ' return base.func1() 'throws: "Not found base not found."
        ' return parent.func1() 'throws: "Not found parent not found."
        ' return MyBaseClass.func1() 'throws: "Not found MyBaseClass not found."
        ' return MyBaseClass::func1() 'throws: "Property not found"
      end function
    
      function func3 as C()
      	debug(1)
      	dim mbc as MyBaseClass
      	debug(1)
      	msgbox(mbc.func2())
        ' How call func2 from here?
        ' return func2() 'throws error "Function: 'func2' was not recognized"
      end function
    end class
    Cornelius

  3. #3
    Member
    Real Name
    Nate Marler
    Join Date
    Apr 2018
    Posts
    17

    Default Re: How to call base class functions?

    Thanks for the reply. I see you've created new objects, but I'm looking to call the original object's base class members. (in fact, you've declared the new variables but not actually instantiated the objects, but I think I get the idea).

Similar Threads

  1. Call xBasic functions from within code block in .a5w file
    By WindForce in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 12-18-2017, 02:05 PM
  2. Can i call UX xbasic functions from a a5w page?
    By WindForce in forum Mobile & Browser Applications
    Replies: 0
    Last Post: 12-06-2017, 04:27 PM
  3. Specify abstract class name in grid 'conditional style and class' window?
    By RichCPT in forum Mobile & Browser Applications
    Replies: 6
    Last Post: 06-29-2017, 03:13 PM
  4. How to call xbasic functions synchronoulsly in dialog component?
    By Parveen in forum Mobile & Browser Applications
    Replies: 4
    Last Post: 12-08-2015, 12:56 PM
  5. Bug - Static class method called from other class doesn't work
    By Steven P. in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 06-28-2011, 10:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •