Script ETeachResult Data Structure is Defined Where?

This forum is dedicated to everything about MemBrain Scripting. All Questions or other contributions with respect to scripting should be placed here.
Especially, if you have an interesting script that you might want to share with other MemBrain users, please post it within a new topic in this forum. Try to choose a title for your topic that allows other users to quickly identify the basic purpose of your script.
Post Reply
MrCreosote
Posts: 55
Joined: Wed 21. Jul 2010, 18:43

Script ETeachResult Data Structure is Defined Where?

Post by MrCreosote »

Where is ETeachResult defined?

I found the Neuron and Link Data Structure definitions inline in the Edit Neurons Script Section - they were defined after script commands which used them.

However, I found ETeachResult used in the GetLastTeachResult() in the Script Teaching Section, however, there was no definition of that data structure following. In fact,

Thanks,
Tom
User avatar
Admin
Site Admin
Posts: 438
Joined: Sun 16. Nov 2008, 18:21

Re: Script ETeachResult Data Structure is Defined Where?

Post by Admin »

'ETeachResult' is an enumeration rather than a data structure. It represents valid return values for the script function 'GetLastTeachResult()'.
It is described in the section 'Teaching' of the 'Script Command Reference' section in the help file (or simply use the serach tab of the help file to search for it).

The following is a copy from the help file that describes the valid enumeration constants:

TR_OK - Normal return value after a single teach step. Also returned if the user stopped the teacher manually.
TR_TARGET_NET_ERROR_REACHED - The teacher detected that the target net error has been reached during teaching.
TR_MAX_NEURONS_ADDED - The teacher reports that the maximum number of neurons has been added without the target net error being reached - Currently only supported by Cascade Correlation teacher.
TR_TEACH_ABORTED - The teach process has been aborted by the user manually.

The data structures for neurons and links can also be found in the help file, simply search for them, they are located in the Command Reference sub section 'Editing Neural Nets'.

Regards,
Thomas Jetter
MrCreosote
Posts: 55
Joined: Wed 21. Jul 2010, 18:43

Re: Script ETeachResult Data Structure is Defined Where?

Post by MrCreosote »

What are the Data Types?
User avatar
Admin
Site Admin
Posts: 438
Joined: Sun 16. Nov 2008, 18:21

Re: Script ETeachResult Data Structure is Defined Where?

Post by Admin »

MrCreosote wrote:What are the Data Types?
Not quite sure if I understand the question...

The data type is 'ETeachResult' which is an enumeration data type. It can be any of the names values. Certainly, behind the scenes the compiler assigns some integer values to the names constants but they should not be of interest.

For example consider the following code snippet:

Code: Select all

ETeachResult result = GetLastTeachResult();

if (result == TR_OK)
{
... // do something
}
else if (result == TR_TARGET_NET_ERROR_REACHED)
{
... // do something
}
else
{
... // do something else
}



or using a switch/case statement:

Code: Select all

ETeachResult result = GetLastTeachResult();

switch (result)
{
    case TR_OK:
        // do something
        break;

    case TR_TARGET_NET_ERROR_REACHED:
        // do something
        break;

    default:
        // do something
}



Does that answer your question?

Regards
Thomas Jetter
Post Reply