CAPL5

25)  getValueSize

Syntax             int getValueSize(EnvVarName);
Function         Returns the size of the environmental variable in bytes. For environmental variables of type string, the string length plus the terminating null character will be returned.     
Parameters     Environment variable name
Returns          Size of the data in bytes
Example
// Size of an environment variable of
// data type integer:
int varSize;
...
varSize = getValueSize(switch);
See also getValue, putValue

26)  inport

Syntax             byte inport(word addr);
Function         Read in a byte from a port.
Parameter      Port address.
Returns          Byte that was reading.
Note                The built-in constants LPT1, LPT2, and LPT3 can be used as a port address.
Example
...
val = inport(0x3f8); // Reads port 0x3f8
...
See also outport

27)  isExtId

Syntax            long isExtId(dword id);
long isExtId(message m);
Function         Checks parameter for extended identifier (29 bit)
Parameters     Variable of type “message” or message ID number
Returns          1 if extended ID, else 0
Example
Passing the message ID as a parameter:
on message * {
if (isExtId(this.ID))
write(“Message with 29-bit identifier
received.”);
}
Passing the message variable as a parameter:
on message * {
if (isExtId(this))
write(“Message with 29-bit identifier
received.”);
}

28)  isStdId

Syntax                         long isStdId(dword id);
long isStdId(message m);
Function                     Checks parameter for standard identifier (11 Bit).
Parameters                 Variable of type “message” or message ID number
Returns                      1 if standard ID, else 0
Example
Passing the message ID as a parameter:
on message * {
if (isStdId(this.ID))
write(“Message with 11-bit identifier
received.”);
}
Passing the message variable as a parameter:
on message * {
if (isStdId(this))
write(“Message with 11-bit identifier
received.”);
}
See also isExtId

29)  keypressed

Syntax                 dword keypressed();
Function         This function returns the key code of a currently pressed key. If no key is being pressed it returns 0. Only one key can be pressed at a time.
Parameters     None
Returns          Key code of pressed key. If the 8 lower bits do not equal 0, keypressed returns the ASCII code of the next key in the keyboard buffer. If the 8 lower bits do not equal 0, the 8 upper bits represent the extended key code (see IBM PC Technical Reference Manual).
Example
variables {
msTimer mytimer; // timer
message 100 msg; // CAN message
}
on key F1 {
setTimer(mytimer,100); // start 100 ms
timer
write(“F1 pressed”); // output to write
window
}
on timer mytimer {
if(keypressed()) { // True if any key is
pressed
setTimer(mytimer,100); // restart timer
output(msg); // send while
keypressed
}
else {
write(“F1 let go”);
}
}

30) ltoa

Syntax              ltoa(long val, string s, long base);
Function         The number val is converted to a string s. In this case, base indicates a number base between 2 and 36. s must be large enough to accept the converted number!
Parameters     val = number to be converted
s = string, which will contain the converted number
base = numeric base
Returns          none
Example
...
long z = 255;
char s1[9];
char s2[9];
ltoa(z, s1, 2); // binary
ltoa(z, s1, 10); // decimal
...
Result: s1 = 11111111, s2 = 255
See also atol

31)  mkExtId

Syntax                dword mkExtId(dword id);
Function         Generate an extended (29-bit) message identifier from a standard (11-bit) message identifier.
Parameter      Message identifier
Returns          Extended message identifier
Example
...
msg.id = mkExtId(this.id);
...

See also isExtId, isStdId, valOfId 



No comments:

Post a Comment