User Space Methods

CreateUserSpace

CreateUserSpace($UserSpaceName, $USLib, $InitSize, $Authority', $InitChar=' ' ) - Creates a User Space object.

 

Arguments

Value

Description

$UserSpaceName

 

User Space name

$USLib

 

User Space library name

$InitSize

1024 - default

The initial size of the User Space being created

$Authority

  •  *ALL - default
  • *CHANGE      
  • *USE       
  • *EXCLUDE
  • *LIBCRTAUT

User Space object authority

$InitChar

 ‘ ‘ - default

The initial value of all bytes in the User Space

Sample Code

Usage Example

$US->CreateUserSpace($US_name, $US_lib, 2000, '*ALL', 'X')

 

RetrieveUserSpaceAttr()

RetrieveUserSpaceAttr() - Retrieves information about the current attributes and the current operational statistics of the User Space.

Sample Code

Usage Example

$USattr-> RetrieveUserSpaceAttr()

 

RetrieveUserSpaceSize()

RetrieveUserSpaceSize() - The Retrieves information about the current size of the User Space.

Sample Code

Usage Example

$USsize-> RetrieveUserSpaceSize()

 

DeleteUserSpace()

DeleteUserSpace() - Removes the User Space object.

Sample Code

Usage Example

$US->DeleteUserSpace();

 

WriteUserSpace

WriteUserSpace($Startpos, $Valuelen, $Value) - Writes data to a User Space object.

 

Arguments

Value

Description

$Startpos

1 - default

The first byte of the User Space from where the data is to be written. It must have a value greater than 0

$Valuelen

 

 The length of the new data. The length must be greater than 0

$Value

 

The new data to be placed into the User Space. The field must be at least as long as the length of the data parameter

Sample Code

Usage Example

$US->WriteUserSpace(1, 100,"Test data");

 

ReadUserSpace

ReadUserSpace($Frompos, $Readlen) - Read data from a User Space object.

 

Arguments

Value

Description

$Frompos

1 - default

The first byte of the User Space from where the data is to be read. It must have a value greater than 0

$Readlen

 

The length of the data to be read. The length must be greater than 0

Sample Code

Usage Example

 $data = $US->ReadUserSpace(1, 50);

 

A PHP Script That Shows The Usage of All User Space Methods

Usage Example

  <pre>
Create/Write/Read/Delete User Space object
<?php
  
include_once 'authorization.php';
include_once '../API/iToolkitService.php';
try {
         $ToolkitServiceObj = ToolkitService::getInstance($db, $user, $pass);
     }
         catch (Exception $e) {              
        echo  $e->getMessage(), "\n";
        exit();
}
$ToolkitServiceObj->setToolkitServiceParams(array('plug'=>"iPLUG1M"));
             
$US = new UserSpace($ToolkitServiceObj);
$US_name = "UTEST";  
$US_lib = "QGPL";
if( !$US->CreateUserSpace($US_name, $US_lib, 2000, '*ALL', 'X'))
{
    echo $US->getError();
    exit();
}
echo $US_lib."/".$US_name;
echo "<br>";
$data = '';
$ret = $US->WriteUserSpace(1, 100,
                            "ABCDEFGHIJ"."ABCDEFGHIJ"."ABCDEFGHIJ"."ABCDEFGHIJ"
                            ."ZZZZZZZZZZ"."ABCDEFGHIJ"."ABCDEFGHIJ"."ABCDEFGHIJ");
if($ret){                         
    $data = $US->ReadUserSpace(1, 50);
    echo "Read from User Space ($US_lib/$US_name) first 50 characters:". $data;                 
}
else
{
    echo "no data read";
}
$US->DeleteUserSpace();
/* Do not use the disconnect() function for "state full" connection */
$ToolkitServiceObj->disconnect();
  
?>
</pre>