[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP OpenVMS DCL Dictionary


Previous Contents Index

F$CUNITS

Converts a number from one specified unit of measure to another.

Format

F$CUNITS (number [,from-units, to-units])

Return Value


A number representing the converted value.

Arguments

number

Specifies a 32-bit (or smaller) number to convert.

from-units

Specifies the unit of measure from which to convert. When only first argument is present, the default option for this field is BLOCKS. Supported options for this field are BLOCKS, B, KB, MB, GB, and TB.

to-units

Specifies the unit of measure to which to convert. When only first argument is present, or the second argument is BLOCKS, the default option for this field is BYTES and the result gets rounded off to appropriate "to-unit". Supported options for this field are BLOCKS, BYTES, B, KB, MB, GB, and TB. Keyword "BYTES" is supported only for BLOCKS to BYTES conversion.

Example


$ WRITE SYS$OUTPUT F$CUNITS(1024)
512KB  
 
$ WRITE SYS$OUTPUT F$CUNITS(1024, "BLOCKS")
512KB 
 
$ WRITE SYS$OUTPUT F$CUNITS(1024, "BLOCKS", "BYTES")
512KB 
      

The above examples convert 1024 blocks to the equivalent in bytes and auto scale the output. The result is 512 KB.


$ WRITE SYS$OUTPUT F$CUNITS(1024, "BLOCKS", "B")
524288B 
      

This example converts 1024 Blocks to non scaled bytes value. The result is 524288 Bytes.


$ WRITE SYS$OUTPUT F$CUNITS (512,"B", "BLOCKS")
1BLOCKS 
      

This example converts 512 Bytes to the equivalent in Blocks. The result is 1 Blocks.


$ WRITE SYS$OUTPUT F$CUNITS (10,"KB","B")
10240B 
      

This example converts 10 KB to the equivalent in Bytes. The result is 10240 Bytes.


$  WRITE SYS$OUTPUT F$CUNITS (1024,"MB","GB")
1GB 
      

This example converts 1024 MB to the equivalent in GB. The result is 1 GB.


$ WRITE SYS$OUTPUT F$CUNITS(512, "MB", "BLOCKS")
1048576BLOCKS 
      

This example converts 512 MB to the equivalent in BLOCKS. The result is 1048576 Blocks.

"CONFLICT" warning message is displayed when keyword "BYTES" is used for other than "BLOCKS" to "BYTES" conversion. For example:


$ WRITE SYS$OUTPUT F$CUNITS (512,"BYTES","BLOCKS") 
%DCL-W-CONFLICT, illegal combination of command elements - check documentation 
\BYTES\
$ WRITE SYS$OUTPUT F$CUNITS (10,"KB","BYTES") 
%DCL-W-CONFLICT, illegal combination of command elements - check documentation 
\BYTES\

The correct syntax to be used is as follows:


$ WRITE SYS$OUTPUT F$CUNITS (512,"B", "BLOCKS") 
1BLOCKS 
$ WRITE SYS$OUTPUT F$CUNITS (10,"KB","B") 
10240B 


Previous Next Contents Index