Loading...
 

Transform

Transform

Transform(name)

Parameter: Name of an enumeration data field or the name of the table or table function.

Stack
Stack Description
Stack(In) integer
Stack(Out) Character string

The value from the stack-top is transformed into a string. The transformation table specified in the parameter is used. The table can be specified directly or indirectly with reference to a data field:

  • The name has the form filename~table name. The specified table is used.
  • The name does not contain a tilde, i.e. a data field was specified. The connection between data field and transformation table is established by CLASSIX.INI. If an access expression is specified, its last term determines the transformation table.

If the transformation table contains several entries with the numerical value searched for, then the entry named first in the table is used.
If the transformation table does not contain a corresponding entry, INVALID is returned.

Note: Before Dll version 227553, "" was returned instead of INVALID.

If the statement finds a string on the stack top, the reverse transformation is performed:

Stack
Stack Description
Stack(In) Character string
Stack(Out) integer

If there are several entries in the translation table for the character string, then the entry named first in the table is selected.
If there is no entry in the translation table for the character string, INVALID is returned.

Before Dll version 227553, 2147483647 (maximum INTEGER value) was returned instead of INVALID.

Example:

// Get the enum out of an object and transform it: item Copy(Monitor("CX_DISPO_ACCOUNT").logisticsEnum) Integer Transform("classix.num~logisticsEnum") // The same a little more comfortable item Copy(Monitor("CX_DISPO_ACCOUNT").logisticsEnum, ENUM) // Do that for initialized integer variables: Var(defaultSetting) 12 -> defaultSetting // If the item has no dispo account, use the default setting item Get(Monitor("CX_DISPO_ACCOUNT")) Dup ifnot { Drop defaultSetting } Integer Transform("classix.num~logisticsEnum") // Transform using a function CX_CLASS Transform("GetClassNames()") //-> "CX_CLASS"

Transform(name, separatorFolge)

parameters: Name of an enumeration data field or the name of the table, separator between two names

Stack
Stack Description
Stack(In) integer
Stack(Out) Character string

For a transformation table, which should only contain values 2n, the value is interpreted by the stack top as a bit field and as a result you get a string consisting of the names of all bits = 1. Successive names are separated by the character string specified in the second parameter.

Example:

/ Definiton in classix.num

/*
batchErrorEnum
{
  1, T("Andere", "Others"), 0xff                                                               // Bit 0
  2, T("Keine Kosten am Fertigungsteil", "No costs on product"), 0xff                          // Bit 1
  4, T("Keine Kosten am Bestellteil/kein SVP", "No costs on purchase item / no svp"), 0xff     // Bit 2
  8, T("Weder Kostenstelle noch Kostenträger", "Neither cost center nor cost objective"), 0xff // Bit 3
 16, T("Fehlende Sachmerkmale", "Missing attributes"), 0xff                                    // Bit 4
 32, T("Fehlendes Logistikkennzeichen", "Missing logistics enum"), 0xff                        // Bit 5
}

  • /

     

// Get the enum out of an object and transform it:

63 Transform("classix.num~batchErrorEnum", ";") // -> "Andere;Keine Kosten am Fertigungsteil;Keine Kosten am Bestellteil/kein SVP;Weder Kostenstelle noch Kostenträger;Fehlende Sachmerkmale;Fehlendes Logistikkennzeichen"

If after the translation into bits the value could not be reduced to 0, then the remainder is added at the end as a numerical value separated by the separator (Ex: ";32"). This also means that in case no bit was found in the passed value, the entire numeric value corresponds to the remainder and is returned as STRING (without the leading separator).

The bit transformation in reverse direction is not available at the moment!

Note: Transform depends on the current language (see instruction Language).
If you need the enumeration name as a multilingual character string, you should use the MLTransform statement