WeixiangYan/CodeTransOcean huggingface dataset:
Task: Delegates


C++: #include <tr1/memory>
#include <string>
#include <iostream>
#include <tr1/functional>

using namespace std;
using namespace std::tr1;
using std::tr1::function;


class IDelegate
{
public:
    virtual ~IDelegate() {}
};


class IThing
{
public:
    virtual ~IThing() {}
    virtual std::string Thing() = 0;
};


class DelegateA : virtual public IDelegate
{
};
 

class DelegateB : public IThing, public IDelegate
{
    std::string Thing()
    {
        return "delegate implementation";
    }
};
 
class Delegator
{
public:
    std::string Operation()
    {
        if(Delegate) 
           if (IThing * pThing = dynamic_cast<IThing*>(Delegate.get()))
            
            return pThing->Thing();
        
        return "default implementation";
    }
 
    shared_ptr<IDelegate> Delegate;
};
 
int main()
{
    shared_ptr<DelegateA> delegateA(new DelegateA());
    shared_ptr<DelegateB> delegateB(new DelegateB());
    Delegator delegator;
 
    
    std::cout << delegator.Operation() << std::endl;
 
    
    delegator.Delegate = delegateA;
    std::cout << delegator.Operation() << std::endl;
 
    
    delegator.Delegate = delegateB;
    std::cout << delegator.Operation() << std::endl;


}
Task: Delegates





Java: interface Thingable {
    String thing();
}

class Delegator {
    public Thingable delegate;

    public String operation() {
        if (delegate == null)
            return "default implementation";
        else
            return delegate.thing();
    }
}

class Delegate implements Thingable {
    public String thing() {
        return "delegate implementation";
    }
}



public class DelegateExample {
    public static void main(String[] args) {
        
        Delegator a = new Delegator();
        assert a.operation().equals("default implementation");

        
        Delegate d = new Delegate();
        a.delegate = d;
        assert a.operation().equals("delegate implementation");

        
        a.delegate = new Thingable() {
                public String thing() {
                    return "anonymous delegate implementation";
                }
            };
        assert a.operation().equals("anonymous delegate implementation");
    }
}
Task: Delegates







Python: class Delegator:
   def __init__(self):
      self.delegate = None
   def operation(self):
       if hasattr(self.delegate, 'thing') and callable(self.delegate.thing):
          return self.delegate.thing()
       return 'default implementation'

class Delegate:
   def thing(self):
      return 'delegate implementation'

if __name__ == '__main__':

   
   a = Delegator()
   assert a.operation() == 'default implementation'

   
   a.delegate = 'A delegate may be any object'
   assert a.operation() == 'default implementation'

   
   a.delegate = Delegate()
   assert a.operation() == 'delegate implementation'
Task: Delegates




Go: package main
import "fmt"

type Delegator struct {
    delegate interface{} 
}


type Thingable interface {
    thing() string
}

func (self Delegator) operation() string {
    if v, ok := self.delegate.(Thingable); ok {
        return v.thing()
    }
    return "default implementation"
}

type Delegate int 

func (Delegate) thing() string {
    return "delegate implementation"
}

func main() {
    
    a := Delegator{}
    fmt.Println(a.operation()) 

    
    a.delegate = "A delegate may be any object"
    fmt.Println(a.operation()) 

    
    var d Delegate
    a.delegate = d
    fmt.Println(a.operation()) 
}
Task: Delegates






PHP: class Delegator {
  function __construct() {
    $this->delegate = NULL ;
  }
  function operation() {
    if(method_exists($this->delegate, "thing"))
      return $this->delegate->thing() ;
    return 'default implementation' ;
  }
}

class Delegate {
  function thing() {
    return 'Delegate Implementation' ;
  }
}

$a = new Delegator() ;
print "{$a->operation()}\n" ;

$a->delegate = 'A delegate may be any object' ;
print "{$a->operation()}\n" ;

$a->delegate = new Delegate() ;
print "{$a->operation()}\n" ;
Task: Delegates






PHP: class Delegator {
  function __construct() {
    $this->delegate = NULL ;
  }
  function operation() {
    if(method_exists($this->delegate, "thing"))
      return $this->delegate->thing() ;
    return 'default implementation' ;
  }
}

class Delegate {
  function thing() {
    return 'Delegate Implementation' ;
  }
}

$a = new Delegator() ;
print "{$a->operation()}\n" ;

$a->delegate = 'A delegate may be any object' ;
print "{$a->operation()}\n" ;

$a->delegate = new Delegate() ;
print "{$a->operation()}\n" ;






Ada: with Ada.Text_IO;  use Ada.Text_IO;

procedure Delegation is
   package Things is
      
      type Object is tagged null record;
      type Object_Ptr is access all Object'Class;
      
      
      type Substantial is new Object with null record;
      function Thing (X : Substantial) return String;
      
      
      type Delegator is new Object with record
         Delegate : Object_Ptr;
      end record;
      function Operation (X : Delegator) return String;
      
      No_Thing  : aliased Object;      
      Has_Thing : aliased Substantial; 
   end Things;
      
   package body Things is
      function Thing (X : Substantial) return String is
      begin
         return "delegate implementation";
      end Thing;
   
      function Operation (X : Delegator) return String is
      begin
         if X.Delegate /= null and then X.Delegate.all in Substantial'Class then
            return Thing (Substantial'Class (X.Delegate.all));
         else
            return "default implementation";
         end if;
      end Operation;
   end Things;

   use Things;

   A : Delegator; 
begin
   Put_Line (A.Operation);
   A.Delegate := No_Thing'Access; 
   Put_Line (A.Operation);
   A.Delegate := Has_Thing'Access; 
   Put_Line (A.Operation);
end Delegation;
Task: Empty string



C#: using System;

namespace EmptyString
{
  class Program
  {
    public static void Main()
    {
      String s = scope .();
      if (s.IsEmpty)
      {
        Console.Writeln("string empty");
      }
      if (!s.IsEmpty)
      {
        Console.Writeln("string not empty");
      }
    }
  }
}









Ada: procedure Empty_String is

   function Is_Empty(S: String) return Boolean is
   begin
      return S = ""; 
   end Is_Empty;

   Empty: String := ""; 
   XXXXX: String := "Not Empty";

begin
   if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
      raise Program_Error with "something went wrong very very badly!!!";
   end if;
end Empty_String;
Task: Empty string

C: #include <string.h>




const char *str = "";


if (str) { ... }


if (str[0] == '\0') { ... }


if ( (str == NULL) || (strlen(str) == 0)) { ... }


if (strcmp(str, "") == 0) { ... }











Ada: procedure Empty_String is

   function Is_Empty(S: String) return Boolean is
   begin
      return S = ""; 
   end Is_Empty;

   Empty: String := ""; 
   XXXXX: String := "Not Empty";

begin
   if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
      raise Program_Error with "something went wrong very very badly!!!";
   end if;
end Empty_String;
Task: Empty string


C++: #include <string>




                     
std::string str;     
std::string str();   
std::string str{};   
std::string str(""); 
std::string str{""}; 



if (str.empty()) { ... } 


if (str.length() == 0) { ... }
if (str == "") { ... }


str.clear();          
str = "";             
str = {};             

                       
std::string tmp{};     
str.swap(tmp);         
std::swap(str, tmp);   



std::string  s_array[100];           
std::array<std::string, 100>  arr;   
std::vector<std::string>(100,"");    


void func( std::string& s = {} ); 










Ada: procedure Empty_String is

   function Is_Empty(S: String) return Boolean is
   begin
      return S = ""; 
   end Is_Empty;

   Empty: String := ""; 
   XXXXX: String := "Not Empty";

begin
   if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
      raise Program_Error with "something went wrong very very badly!!!";
   end if;
end Empty_String;
Task: Empty string




Go: 
var s string
s2 := ""


s = ""


s == ""
len(s) == 0


s != ""
len(s) != 0 








Ada: procedure Empty_String is

   function Is_Empty(S: String) return Boolean is
   begin
      return S = ""; 
   end Is_Empty;

   Empty: String := ""; 
   XXXXX: String := "Not Empty";

begin
   if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
      raise Program_Error with "something went wrong very very badly!!!";
   end if;
end Empty_String;
Task: Empty string





Java: String s = "";
if(s != null && s.isEmpty()){
   System.out.println("s is empty");
}else{
   System.out.println("s is not empty");
}







Ada: procedure Empty_String is

   function Is_Empty(S: String) return Boolean is
   begin
      return S = ""; 
   end Is_Empty;

   Empty: String := ""; 
   XXXXX: String := "Not Empty";

begin
   if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
      raise Program_Error with "something went wrong very very badly!!!";
   end if;
end Empty_String;
Task: Empty string







Python: s = ''

s = str()

if not s or s == '':
   print("String is empty")

if len(s) == 0:
    print("String is empty")
else:
    print("String not empty")






def emptystring(s):
   if isinstance(s, (''.__class__ , u''.__class__) ):
      if len(s) == 0: 
         return True
      else 
         return False

   elif s is None:
        return True





Ada: procedure Empty_String is

   function Is_Empty(S: String) return Boolean is
   begin
      return S = ""; 
   end Is_Empty;

   Empty: String := ""; 
   XXXXX: String := "Not Empty";

begin
   if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
      raise Program_Error with "something went wrong very very badly!!!";
   end if;
end Empty_String;
Task: Empty string








VB: dim s as string


s = ""

s = vbNullString



if s = "" then Debug.Print "empty!"

if Len(s) = 0 then Debug.Print "still empty!"


if s <> "" then Debug.Print "not an empty string"

if Len(s) > 0 then Debug.Print "not empty."




Ada: procedure Empty_String is

   function Is_Empty(S: String) return Boolean is
   begin
      return S = ""; 
   end Is_Empty;

   Empty: String := ""; 
   XXXXX: String := "Not Empty";

begin
   if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
      raise Program_Error with "something went wrong very very badly!!!";
   end if;
end Empty_String;
Task: Empty string

C: #include <string.h>




const char *str = "";


if (str) { ... }


if (str[0] == '\0') { ... }


if ( (str == NULL) || (strlen(str) == 0)) { ... }


if (strcmp(str, "") == 0) { ... }
Task: Empty string



C#: using System;

namespace EmptyString
{
  class Program
  {
    public static void Main()
    {
      String s = scope .();
      if (s.IsEmpty)
      {
        Console.Writeln("string empty");
      }
      if (!s.IsEmpty)
      {
        Console.Writeln("string not empty");
      }
    }
  }
}
Task: Empty string


C++: #include <string>




                     
std::string str;     
std::string str();   
std::string str{};   
std::string str(""); 
std::string str{""}; 



if (str.empty()) { ... } 


if (str.length() == 0) { ... }
if (str == "") { ... }


str.clear();          
str = "";             
str = {};             

                       
std::string tmp{};     
str.swap(tmp);         
std::swap(str, tmp);   



std::string  s_array[100];           
std::array<std::string, 100>  arr;   
std::vector<std::string>(100,"");    


void func( std::string& s = {} );
Task: Empty string





Java: String s = "";
if(s != null && s.isEmpty()){
   System.out.println("s is empty");
}else{
   System.out.println("s is not empty");
}
Task: Empty string







Python: s = ''

s = str()

if not s or s == '':
   print("String is empty")

if len(s) == 0:
    print("String is empty")
else:
    print("String not empty")






def emptystring(s):
   if isinstance(s, (''.__class__ , u''.__class__) ):
      if len(s) == 0: 
         return True
      else 
         return False

   elif s is None:
        return True
Task: Empty string








VB: dim s as string


s = ""

s = vbNullString



if s = "" then Debug.Print "empty!"

if Len(s) = 0 then Debug.Print "still empty!"


if s <> "" then Debug.Print "not an empty string"

if Len(s) > 0 then Debug.Print "not empty."
Task: Empty string




Go: 
var s string
s2 := ""


s = ""


s == ""
len(s) == 0


s != ""
len(s) != 0
Task: Empty string



C#: using System;

namespace EmptyString
{
  class Program
  {
    public static void Main()
    {
      String s = scope .();
      if (s.IsEmpty)
      {
        Console.Writeln("string empty");
      }
      if (!s.IsEmpty)
      {
        Console.Writeln("string not empty");
      }
    }
  }
}








Fortran:       SUBROUTINE TASTE(T)
       CHARACTER*(*) T       
        IF (LEN(T).LE.0) WRITE(6,*) "Empty
        IF (LEN(T).GT.0) WRITE(6,*) "Not empty
      END
      CHARACTER*24 TEXT
      CALL TASTE("")
      CALL TASTE("This")
      TEXT = ""              
      CALL TASTE(TEXT)       
      END
Task: Empty string


C++: #include <string>




                     
std::string str;     
std::string str();   
std::string str{};   
std::string str(""); 
std::string str{""}; 



if (str.empty()) { ... } 


if (str.length() == 0) { ... }
if (str == "") { ... }


str.clear();          
str = "";             
str = {};             

                       
std::string tmp{};     
str.swap(tmp);         
std::swap(str, tmp);   



std::string  s_array[100];           
std::array<std::string, 100>  arr;   
std::vector<std::string>(100,"");    


void func( std::string& s = {} ); 









Fortran:       SUBROUTINE TASTE(T)
       CHARACTER*(*) T       
        IF (LEN(T).LE.0) WRITE(6,*) "Empty
        IF (LEN(T).GT.0) WRITE(6,*) "Not empty
      END
      CHARACTER*24 TEXT
      CALL TASTE("")
      CALL TASTE("This")
      TEXT = ""              
      CALL TASTE(TEXT)       
      END
Task: Empty string

C: #include <string.h>




const char *str = "";


if (str) { ... }


if (str[0] == '\0') { ... }


if ( (str == NULL) || (strlen(str) == 0)) { ... }


if (strcmp(str, "") == 0) { ... }










Fortran:       SUBROUTINE TASTE(T)
       CHARACTER*(*) T       
        IF (LEN(T).LE.0) WRITE(6,*) "Empty
        IF (LEN(T).GT.0) WRITE(6,*) "Not empty
      END
      CHARACTER*24 TEXT
      CALL TASTE("")
      CALL TASTE("This")
      TEXT = ""              
      CALL TASTE(TEXT)       
      END
Task: Empty string




Go: 
var s string
s2 := ""


s = ""


s == ""
len(s) == 0


s != ""
len(s) != 0 







Fortran:       SUBROUTINE TASTE(T)
       CHARACTER*(*) T       
        IF (LEN(T).LE.0) WRITE(6,*) "Empty
        IF (LEN(T).GT.0) WRITE(6,*) "Not empty
      END
      CHARACTER*24 TEXT
      CALL TASTE("")
      CALL TASTE("This")
      TEXT = ""              
      CALL TASTE(TEXT)       
      END
Task: Empty string





Java: String s = "";
if(s != null && s.isEmpty()){
   System.out.println("s is empty");
}else{
   System.out.println("s is not empty");
}






Fortran:       SUBROUTINE TASTE(T)
       CHARACTER*(*) T       
        IF (LEN(T).LE.0) WRITE(6,*) "Empty
        IF (LEN(T).GT.0) WRITE(6,*) "Not empty
      END
      CHARACTER*24 TEXT
      CALL TASTE("")
      CALL TASTE("This")
      TEXT = ""              
      CALL TASTE(TEXT)       
      END
Task: Empty string







Python: s = ''

s = str()

if not s or s == '':
   print("String is empty")

if len(s) == 0:
    print("String is empty")
else:
    print("String not empty")






def emptystring(s):
   if isinstance(s, (''.__class__ , u''.__class__) ):
      if len(s) == 0: 
         return True
      else 
         return False

   elif s is None:
        return True




Fortran:       SUBROUTINE TASTE(T)
       CHARACTER*(*) T       
        IF (LEN(T).LE.0) WRITE(6,*) "Empty
        IF (LEN(T).GT.0) WRITE(6,*) "Not empty
      END
      CHARACTER*24 TEXT
      CALL TASTE("")
      CALL TASTE("This")
      TEXT = ""              
      CALL TASTE(TEXT)       
      END
Task: Empty string








VB: dim s as string


s = ""

s = vbNullString



if s = "" then Debug.Print "empty!"

if Len(s) = 0 then Debug.Print "still empty!"


if s <> "" then Debug.Print "not an empty string"

if Len(s) > 0 then Debug.Print "not empty."



Fortran:       SUBROUTINE TASTE(T)
       CHARACTER*(*) T       
        IF (LEN(T).LE.0) WRITE(6,*) "Empty
        IF (LEN(T).GT.0) WRITE(6,*) "Not empty
      END
      CHARACTER*24 TEXT
      CALL TASTE("")
      CALL TASTE("This")
      TEXT = ""              
      CALL TASTE(TEXT)       
      END
Task: Empty string






PHP: <?php

$str = ''; // assign an empty string to a variable

if (empty($str)) { ... }

if (! empty($str)) { ... }

if ($str == '') { ... }
if ($str != '') { ... }

if (strlen($str) == 0) { ... }
if (strlen($str) != 0) { ... }





Fortran:       SUBROUTINE TASTE(T)
       CHARACTER*(*) T       
        IF (LEN(T).LE.0) WRITE(6,*) "Empty
        IF (LEN(T).GT.0) WRITE(6,*) "Not empty
      END
      CHARACTER*24 TEXT
      CALL TASTE("")
      CALL TASTE("This")
      TEXT = ""              
      CALL TASTE(TEXT)       
      END
Task: Empty string

C: #include <string.h>




const char *str = "";


if (str) { ... }


if (str[0] == '\0') { ... }


if ( (str == NULL) || (strlen(str) == 0)) { ... }


if (strcmp(str, "") == 0) { ... }









COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.    EMPTYSTR.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                     PIC X(10).

       PROCEDURE DIVISION.
       Begin.

*     *    Assign an empty string.
           INITIALIZE str.

*     *    Or
           MOVE " " TO str.

           IF (str = " ")
              DISPLAY "String is empty"
           ELSE
              DISPLAY "String is not empty"
           END-IF.

           STOP RUN.
Task: Empty string



C#: using System;

namespace EmptyString
{
  class Program
  {
    public static void Main()
    {
      String s = scope .();
      if (s.IsEmpty)
      {
        Console.Writeln("string empty");
      }
      if (!s.IsEmpty)
      {
        Console.Writeln("string not empty");
      }
    }
  }
}







COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.    EMPTYSTR.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                     PIC X(10).

       PROCEDURE DIVISION.
       Begin.

*     *    Assign an empty string.
           INITIALIZE str.

*     *    Or
           MOVE " " TO str.

           IF (str = " ")
              DISPLAY "String is empty"
           ELSE
              DISPLAY "String is not empty"
           END-IF.

           STOP RUN.
Task: Empty string


C++: #include <string>




                     
std::string str;     
std::string str();   
std::string str{};   
std::string str(""); 
std::string str{""}; 



if (str.empty()) { ... } 


if (str.length() == 0) { ... }
if (str == "") { ... }


str.clear();          
str = "";             
str = {};             

                       
std::string tmp{};     
str.swap(tmp);         
std::swap(str, tmp);   



std::string  s_array[100];           
std::array<std::string, 100>  arr;   
std::vector<std::string>(100,"");    


void func( std::string& s = {} ); 








COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.    EMPTYSTR.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                     PIC X(10).

       PROCEDURE DIVISION.
       Begin.

*     *    Assign an empty string.
           INITIALIZE str.

*     *    Or
           MOVE " " TO str.

           IF (str = " ")
              DISPLAY "String is empty"
           ELSE
              DISPLAY "String is not empty"
           END-IF.

           STOP RUN.
Task: Empty string





Java: String s = "";
if(s != null && s.isEmpty()){
   System.out.println("s is empty");
}else{
   System.out.println("s is not empty");
}





COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.    EMPTYSTR.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                     PIC X(10).

       PROCEDURE DIVISION.
       Begin.

*     *    Assign an empty string.
           INITIALIZE str.

*     *    Or
           MOVE " " TO str.

           IF (str = " ")
              DISPLAY "String is empty"
           ELSE
              DISPLAY "String is not empty"
           END-IF.

           STOP RUN.
Task: Empty string







Python: s = ''

s = str()

if not s or s == '':
   print("String is empty")

if len(s) == 0:
    print("String is empty")
else:
    print("String not empty")






def emptystring(s):
   if isinstance(s, (''.__class__ , u''.__class__) ):
      if len(s) == 0: 
         return True
      else 
         return False

   elif s is None:
        return True



COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.    EMPTYSTR.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                     PIC X(10).

       PROCEDURE DIVISION.
       Begin.

*     *    Assign an empty string.
           INITIALIZE str.

*     *    Or
           MOVE " " TO str.

           IF (str = " ")
              DISPLAY "String is empty"
           ELSE
              DISPLAY "String is not empty"
           END-IF.

           STOP RUN.
Task: Empty string








VB: dim s as string


s = ""

s = vbNullString



if s = "" then Debug.Print "empty!"

if Len(s) = 0 then Debug.Print "still empty!"


if s <> "" then Debug.Print "not an empty string"

if Len(s) > 0 then Debug.Print "not empty."


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.    EMPTYSTR.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                     PIC X(10).

       PROCEDURE DIVISION.
       Begin.

*     *    Assign an empty string.
           INITIALIZE str.

*     *    Or
           MOVE " " TO str.

           IF (str = " ")
              DISPLAY "String is empty"
           ELSE
              DISPLAY "String is not empty"
           END-IF.

           STOP RUN.
Task: Empty string




Go: 
var s string
s2 := ""


s = ""


s == ""
len(s) == 0


s != ""
len(s) != 0 






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.    EMPTYSTR.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                     PIC X(10).

       PROCEDURE DIVISION.
       Begin.

*     *    Assign an empty string.
           INITIALIZE str.

*     *    Or
           MOVE " " TO str.

           IF (str = " ")
              DISPLAY "String is empty"
           ELSE
              DISPLAY "String is not empty"
           END-IF.

           STOP RUN.
Task: Empty string






PHP: <?php

$str = ''; // assign an empty string to a variable

if (empty($str)) { ... }

if (! empty($str)) { ... }

if ($str == '') { ... }
if ($str != '') { ... }

if (strlen($str) == 0) { ... }
if (strlen($str) != 0) { ... }
Task: Empty string






PHP: <?php

$str = ''; // assign an empty string to a variable

if (empty($str)) { ... }

if (! empty($str)) { ... }

if ($str == '') { ... }
if ($str != '') { ... }

if (strlen($str) == 0) { ... }
if (strlen($str) != 0) { ... }






Ada: procedure Empty_String is

   function Is_Empty(S: String) return Boolean is
   begin
      return S = ""; 
   end Is_Empty;

   Empty: String := ""; 
   XXXXX: String := "Not Empty";

begin
   if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
      raise Program_Error with "something went wrong very very badly!!!";
   end if;
end Empty_String;
Task: Empty string






PHP: <?php

$str = ''; // assign an empty string to a variable

if (empty($str)) { ... }

if (! empty($str)) { ... }

if ($str == '') { ... }
if ($str != '') { ... }

if (strlen($str) == 0) { ... }
if (strlen($str) != 0) { ... }




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID.    EMPTYSTR.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  str                     PIC X(10).

       PROCEDURE DIVISION.
       Begin.

*     *    Assign an empty string.
           INITIALIZE str.

*     *    Or
           MOVE " " TO str.

           IF (str = " ")
              DISPLAY "String is empty"
           ELSE
              DISPLAY "String is not empty"
           END-IF.

           STOP RUN.