WeixiangYan/CodeTransOcean huggingface dataset:
Task: Show the epoch








VB: Sub Main()
    Debug.Print Format(0, "dd mmm yyyy hh:mm")
End Sub


COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. epoch.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  epoch-date.
           03  year                PIC 9(4).
           03  month               PIC 99.
           03  dday                PIC 99.

       PROCEDURE DIVISION.
           MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date

           DISPLAY year "-" month "-" dday

           GOBACK
           .
Task: Show the epoch




Go: package main
import ("fmt"; "time")

func main() {
    fmt.Println(time.Time{})
}






COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. epoch.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  epoch-date.
           03  year                PIC 9(4).
           03  month               PIC 99.
           03  dday                PIC 99.

       PROCEDURE DIVISION.
           MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date

           DISPLAY year "-" month "-" dday

           GOBACK
           .
Task: Show the epoch






PHP: <?php
echo gmdate('r', 0), "\n";
?>
Task: Show the epoch






PHP: <?php
echo gmdate('r', 0), "\n";
?>






Ada: with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Calendar.Conversions; use Ada.Calendar.Conversions;
procedure ShowEpoch is
   etime : Time := To_Ada_Time (0);
begin
   Put_Line (Image (Date => etime));
end ShowEpoch;
Task: Show the epoch






PHP: <?php
echo gmdate('r', 0), "\n";
?>




COBOL:        IDENTIFICATION DIVISION.
       PROGRAM-ID. epoch.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  epoch-date.
           03  year                PIC 9(4).
           03  month               PIC 99.
           03  dday                PIC 99.

       PROCEDURE DIVISION.
           MOVE FUNCTION DATE-OF-INTEGER(1) TO epoch-date

           DISPLAY year "-" month "-" dday

           GOBACK
           .
Task: File size



C#: using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(new FileInfo("/input.txt").Length);
        Console.WriteLine(new FileInfo("input.txt").Length);
    }
}









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

procedure Test_File_Size is
begin
   Put_Line (File_Size'Image (Size ("input.txt")) & " bytes");
   Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes");
end Test_File_Size;
Task: File size

C: #include <stdlib.h>
#include <stdio.h>

long getFileSize(const char *filename)
{
  long result;
  FILE *fh = fopen(filename, "rb");
  fseek(fh, 0, SEEK_END);
  result = ftell(fh);
  fclose(fh);
  return result;
}

int main(void)
{
  printf("%ld\n", getFileSize("input.txt"));
  printf("%ld\n", getFileSize("/input.txt"));
  return 0;
}











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

procedure Test_File_Size is
begin
   Put_Line (File_Size'Image (Size ("input.txt")) & " bytes");
   Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes");
end Test_File_Size;
Task: File size


C++: #include <iostream>
#include <fstream>

std::ios::off_type getFileSize(const char *filename) {
  std::ifstream f(filename);
  std::ios::pos_type begin = f.tellg();
  f.seekg(0, std::ios::end);
  std::ios::pos_type end = f.tellg();
  return end - begin;
}

int main() {
  std::cout << getFileSize("input.txt") << std::endl;
  std::cout << getFileSize("/input.txt") << std::endl;
  return 0;
}










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

procedure Test_File_Size is
begin
   Put_Line (File_Size'Image (Size ("input.txt")) & " bytes");
   Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes");
end Test_File_Size;
Task: File size




Go: package main

import "fmt"
import "os"

func printFileSize(f string) {
    if stat, err := os.Stat(f); err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(stat.Size())
    }
}

func main() {
    printFileSize("input.txt")
    printFileSize("/input.txt")
}








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

procedure Test_File_Size is
begin
   Put_Line (File_Size'Image (Size ("input.txt")) & " bytes");
   Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes");
end Test_File_Size;
Task: File size





Java: import java.io.File;

public class FileSize
{
    public static void main ( String[] args )
    {
        System.out.println("input.txt  : " + new File("input.txt").length() + " bytes");
        System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes");
    }
}







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

procedure Test_File_Size is
begin
   Put_Line (File_Size'Image (Size ("input.txt")) & " bytes");
   Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes");
end Test_File_Size;
Task: File size







Python: import os

size = os.path.getsize('input.txt')
size = os.path.getsize('/input.txt')





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

procedure Test_File_Size is
begin
   Put_Line (File_Size'Image (Size ("input.txt")) & " bytes");
   Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes");
end Test_File_Size;
Task: File size








VB: Option Explicit

----

Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String)
Dim i As Long
  If InStr(Len(Path), Path, "\") = 0 Then
    Path = Path & "\"
  End If
  On Error Resume Next 
  i = FileLen(Path & Filename)
  If Err.Number = 0 Then
    Debug.Print "file size: " & CStr(i) & " Bytes"
  Else
    Debug.Print "error: " & Err.Description
  End If
End Sub

----

Sub Main()
  DisplayFileSize CurDir(), "input.txt"
  DisplayFileSize CurDir(), "innputt.txt"
  DisplayFileSize Environ$("SystemRoot"), "input.txt"
End Sub




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

procedure Test_File_Size is
begin
   Put_Line (File_Size'Image (Size ("input.txt")) & " bytes");
   Put_Line (File_Size'Image (Size ("/input.txt")) & " bytes");
end Test_File_Size;
Task: File size

C: #include <stdlib.h>
#include <stdio.h>

long getFileSize(const char *filename)
{
  long result;
  FILE *fh = fopen(filename, "rb");
  fseek(fh, 0, SEEK_END);
  result = ftell(fh);
  fclose(fh);
  return result;
}

int main(void)
{
  printf("%ld\n", getFileSize("input.txt"));
  printf("%ld\n", getFileSize("/input.txt"));
  return 0;
}
Task: File size



C#: using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(new FileInfo("/input.txt").Length);
        Console.WriteLine(new FileInfo("input.txt").Length);
    }
}
Task: File size


C++: #include <iostream>
#include <fstream>

std::ios::off_type getFileSize(const char *filename) {
  std::ifstream f(filename);
  std::ios::pos_type begin = f.tellg();
  f.seekg(0, std::ios::end);
  std::ios::pos_type end = f.tellg();
  return end - begin;
}

int main() {
  std::cout << getFileSize("input.txt") << std::endl;
  std::cout << getFileSize("/input.txt") << std::endl;
  return 0;
}
Task: File size





Java: import java.io.File;

public class FileSize
{
    public static void main ( String[] args )
    {
        System.out.println("input.txt  : " + new File("input.txt").length() + " bytes");
        System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes");
    }
}
Task: File size







Python: import os

size = os.path.getsize('input.txt')
size = os.path.getsize('/input.txt')
Task: File size








VB: Option Explicit

----

Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String)
Dim i As Long
  If InStr(Len(Path), Path, "\") = 0 Then
    Path = Path & "\"
  End If
  On Error Resume Next 
  i = FileLen(Path & Filename)
  If Err.Number = 0 Then
    Debug.Print "file size: " & CStr(i) & " Bytes"
  Else
    Debug.Print "error: " & Err.Description
  End If
End Sub

----

Sub Main()
  DisplayFileSize CurDir(), "input.txt"
  DisplayFileSize CurDir(), "innputt.txt"
  DisplayFileSize Environ$("SystemRoot"), "input.txt"
End Sub
Task: File size




Go: package main

import "fmt"
import "os"

func printFileSize(f string) {
    if stat, err := os.Stat(f); err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(stat.Size())
    }
}

func main() {
    printFileSize("input.txt")
    printFileSize("/input.txt")
}
Task: File size



C#: using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(new FileInfo("/input.txt").Length);
        Console.WriteLine(new FileInfo("input.txt").Length);
    }
}








Fortran:     use :: iso_fortran_env, only : FILE_STORAGE_SIZE
    implicit none
    character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt']
    integer                    :: file_size, i
    do i=1,size(filename)
       INQUIRE(FILE=filename(i), SIZE=file_size)  
       write(*,*)'size of file '//trim(filename(i))//' is ',file_size * FILE_STORAGE_SIZE /8,' bytes'
    enddo
    end
Task: File size


C++: #include <iostream>
#include <fstream>

std::ios::off_type getFileSize(const char *filename) {
  std::ifstream f(filename);
  std::ios::pos_type begin = f.tellg();
  f.seekg(0, std::ios::end);
  std::ios::pos_type end = f.tellg();
  return end - begin;
}

int main() {
  std::cout << getFileSize("input.txt") << std::endl;
  std::cout << getFileSize("/input.txt") << std::endl;
  return 0;
}









Fortran:     use :: iso_fortran_env, only : FILE_STORAGE_SIZE
    implicit none
    character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt']
    integer                    :: file_size, i
    do i=1,size(filename)
       INQUIRE(FILE=filename(i), SIZE=file_size)  
       write(*,*)'size of file '//trim(filename(i))//' is ',file_size * FILE_STORAGE_SIZE /8,' bytes'
    enddo
    end
Task: File size

C: #include <stdlib.h>
#include <stdio.h>

long getFileSize(const char *filename)
{
  long result;
  FILE *fh = fopen(filename, "rb");
  fseek(fh, 0, SEEK_END);
  result = ftell(fh);
  fclose(fh);
  return result;
}

int main(void)
{
  printf("%ld\n", getFileSize("input.txt"));
  printf("%ld\n", getFileSize("/input.txt"));
  return 0;
}










Fortran:     use :: iso_fortran_env, only : FILE_STORAGE_SIZE
    implicit none
    character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt']
    integer                    :: file_size, i
    do i=1,size(filename)
       INQUIRE(FILE=filename(i), SIZE=file_size)  
       write(*,*)'size of file '//trim(filename(i))//' is ',file_size * FILE_STORAGE_SIZE /8,' bytes'
    enddo
    end
Task: File size




Go: package main

import "fmt"
import "os"

func printFileSize(f string) {
    if stat, err := os.Stat(f); err != nil {
        fmt.Println(err)
    } else {
        fmt.Println(stat.Size())
    }
}

func main() {
    printFileSize("input.txt")
    printFileSize("/input.txt")
}







Fortran:     use :: iso_fortran_env, only : FILE_STORAGE_SIZE
    implicit none
    character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt']
    integer                    :: file_size, i
    do i=1,size(filename)
       INQUIRE(FILE=filename(i), SIZE=file_size)  
       write(*,*)'size of file '//trim(filename(i))//' is ',file_size * FILE_STORAGE_SIZE /8,' bytes'
    enddo
    end
Task: File size





Java: import java.io.File;

public class FileSize
{
    public static void main ( String[] args )
    {
        System.out.println("input.txt  : " + new File("input.txt").length() + " bytes");
        System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes");
    }
}






Fortran:     use :: iso_fortran_env, only : FILE_STORAGE_SIZE
    implicit none
    character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt']
    integer                    :: file_size, i
    do i=1,size(filename)
       INQUIRE(FILE=filename(i), SIZE=file_size)  
       write(*,*)'size of file '//trim(filename(i))//' is ',file_size * FILE_STORAGE_SIZE /8,' bytes'
    enddo
    end
Task: File size







Python: import os

size = os.path.getsize('input.txt')
size = os.path.getsize('/input.txt')




Fortran:     use :: iso_fortran_env, only : FILE_STORAGE_SIZE
    implicit none
    character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt']
    integer                    :: file_size, i
    do i=1,size(filename)
       INQUIRE(FILE=filename(i), SIZE=file_size)  
       write(*,*)'size of file '//trim(filename(i))//' is ',file_size * FILE_STORAGE_SIZE /8,' bytes'
    enddo
    end
Task: File size








VB: Option Explicit

----

Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String)
Dim i As Long
  If InStr(Len(Path), Path, "\") = 0 Then
    Path = Path & "\"
  End If
  On Error Resume Next 
  i = FileLen(Path & Filename)
  If Err.Number = 0 Then
    Debug.Print "file size: " & CStr(i) & " Bytes"
  Else
    Debug.Print "error: " & Err.Description
  End If
End Sub

----

Sub Main()
  DisplayFileSize CurDir(), "input.txt"
  DisplayFileSize CurDir(), "innputt.txt"
  DisplayFileSize Environ$("SystemRoot"), "input.txt"
End Sub



Fortran:     use :: iso_fortran_env, only : FILE_STORAGE_SIZE
    implicit none
    character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt']
    integer                    :: file_size, i
    do i=1,size(filename)
       INQUIRE(FILE=filename(i), SIZE=file_size)  
       write(*,*)'size of file '//trim(filename(i))//' is ',file_size * FILE_STORAGE_SIZE /8,' bytes'
    enddo
    end
Task: File size






PHP: <?php
echo filesize('input.txt'), "\n";
echo filesize('/input.txt'), "\n";
?>





Fortran:     use :: iso_fortran_env, only : FILE_STORAGE_SIZE
    implicit none
    character(len=*),parameter :: filename(*)=[character(len=256) :: 'input.txt', '/input.txt']
    integer                    :: file_size, i
    do i=1,size(filename)
       INQUIRE(FILE=filename(i), SIZE=file_size)  
       write(*,*)'size of file '//trim(filename(i))//' is ',file_size * FILE_STORAGE_SIZE /8,' bytes'
    enddo
    end
Task: File size

C: #include <stdlib.h>
#include <stdio.h>

long getFileSize(const char *filename)
{
  long result;
  FILE *fh = fopen(filename, "rb");
  fseek(fh, 0, SEEK_END);
  result = ftell(fh);
  fclose(fh);
  return result;
}

int main(void)
{
  printf("%ld\n", getFileSize("input.txt"));
  printf("%ld\n", getFileSize("/input.txt"));
  return 0;
}









COBOL:        identification division.
       program-id. FileInfo.

       data division.
       working-storage section.
       01  file-name              pic x(256).
       01  file-size-edited       pic zzz,zzz,zzz.
       01  file-details.
           05 file-size           pic x(8) comp-x.
           05 file-date.
              10 file-day         pic x comp-x.
              10 file-month       pic x comp-x.
              10 file-year        pic xx comp-x.
           05 file-time.
              10 file-hour        pic x comp-x.
              10 file-minute      pic x comp-x.
              10 file-second      pic x comp-x.
              10 file-hundredths  pic x comp-x.

       procedure division.
       main.
           move "input.txt" to file-name
           perform file-info
           
           move "\input.txt" to file-name
           perform file-info

           stop run
           .

       file-info.
           call "CBL_CHECK_FILE_EXIST" 
              using file-name, file-details
              returning return-code
           if return-code = 0
              move file-size to file-size-edited
              display function trim(file-name) " "
                      function trim(file-size-edited) " Bytes"
           else
              display function trim(file-name) " not found!"
           end-if
           .
Task: File size



C#: using System;
using System.IO;

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(new FileInfo("/input.txt").Length);
        Console.WriteLine(new FileInfo("input.txt").Length);
    }
}







COBOL:        identification division.
       program-id. FileInfo.

       data division.
       working-storage section.
       01  file-name              pic x(256).
       01  file-size-edited       pic zzz,zzz,zzz.
       01  file-details.
           05 file-size           pic x(8) comp-x.
           05 file-date.
              10 file-day         pic x comp-x.
              10 file-month       pic x comp-x.
              10 file-year        pic xx comp-x.
           05 file-time.
              10 file-hour        pic x comp-x.
              10 file-minute      pic x comp-x.
              10 file-second      pic x comp-x.
              10 file-hundredths  pic x comp-x.

       procedure division.
       main.
           move "input.txt" to file-name
           perform file-info
           
           move "\input.txt" to file-name
           perform file-info

           stop run
           .

       file-info.
           call "CBL_CHECK_FILE_EXIST" 
              using file-name, file-details
              returning return-code
           if return-code = 0
              move file-size to file-size-edited
              display function trim(file-name) " "
                      function trim(file-size-edited) " Bytes"
           else
              display function trim(file-name) " not found!"
           end-if
           .
Task: File size


C++: #include <iostream>
#include <fstream>

std::ios::off_type getFileSize(const char *filename) {
  std::ifstream f(filename);
  std::ios::pos_type begin = f.tellg();
  f.seekg(0, std::ios::end);
  std::ios::pos_type end = f.tellg();
  return end - begin;
}

int main() {
  std::cout << getFileSize("input.txt") << std::endl;
  std::cout << getFileSize("/input.txt") << std::endl;
  return 0;
}








COBOL:        identification division.
       program-id. FileInfo.

       data division.
       working-storage section.
       01  file-name              pic x(256).
       01  file-size-edited       pic zzz,zzz,zzz.
       01  file-details.
           05 file-size           pic x(8) comp-x.
           05 file-date.
              10 file-day         pic x comp-x.
              10 file-month       pic x comp-x.
              10 file-year        pic xx comp-x.
           05 file-time.
              10 file-hour        pic x comp-x.
              10 file-minute      pic x comp-x.
              10 file-second      pic x comp-x.
              10 file-hundredths  pic x comp-x.

       procedure division.
       main.
           move "input.txt" to file-name
           perform file-info
           
           move "\input.txt" to file-name
           perform file-info

           stop run
           .

       file-info.
           call "CBL_CHECK_FILE_EXIST" 
              using file-name, file-details
              returning return-code
           if return-code = 0
              move file-size to file-size-edited
              display function trim(file-name) " "
                      function trim(file-size-edited) " Bytes"
           else
              display function trim(file-name) " not found!"
           end-if
           .
Task: File size





Java: import java.io.File;

public class FileSize
{
    public static void main ( String[] args )
    {
        System.out.println("input.txt  : " + new File("input.txt").length() + " bytes");
        System.out.println("/input.txt : " + new File("/input.txt").length() + " bytes");
    }
}





COBOL:        identification division.
       program-id. FileInfo.

       data division.
       working-storage section.
       01  file-name              pic x(256).
       01  file-size-edited       pic zzz,zzz,zzz.
       01  file-details.
           05 file-size           pic x(8) comp-x.
           05 file-date.
              10 file-day         pic x comp-x.
              10 file-month       pic x comp-x.
              10 file-year        pic xx comp-x.
           05 file-time.
              10 file-hour        pic x comp-x.
              10 file-minute      pic x comp-x.
              10 file-second      pic x comp-x.
              10 file-hundredths  pic x comp-x.

       procedure division.
       main.
           move "input.txt" to file-name
           perform file-info
           
           move "\input.txt" to file-name
           perform file-info

           stop run
           .

       file-info.
           call "CBL_CHECK_FILE_EXIST" 
              using file-name, file-details
              returning return-code
           if return-code = 0
              move file-size to file-size-edited
              display function trim(file-name) " "
                      function trim(file-size-edited) " Bytes"
           else
              display function trim(file-name) " not found!"
           end-if
           .
Task: File size







Python: import os

size = os.path.getsize('input.txt')
size = os.path.getsize('/input.txt')



COBOL:        identification division.
       program-id. FileInfo.

       data division.
       working-storage section.
       01  file-name              pic x(256).
       01  file-size-edited       pic zzz,zzz,zzz.
       01  file-details.
           05 file-size           pic x(8) comp-x.
           05 file-date.
              10 file-day         pic x comp-x.
              10 file-month       pic x comp-x.
              10 file-year        pic xx comp-x.
           05 file-time.
              10 file-hour        pic x comp-x.
              10 file-minute      pic x comp-x.
              10 file-second      pic x comp-x.
              10 file-hundredths  pic x comp-x.

       procedure division.
       main.
           move "input.txt" to file-name
           perform file-info
           
           move "\input.txt" to file-name
           perform file-info

           stop run
           .

       file-info.
           call "CBL_CHECK_FILE_EXIST" 
              using file-name, file-details
              returning return-code
           if return-code = 0
              move file-size to file-size-edited
              display function trim(file-name) " "
                      function trim(file-size-edited) " Bytes"
           else
              display function trim(file-name) " not found!"
           end-if
           .