native.jc

来自「The JILRunOnly project is a simple comma」· JC 代码 · 共 49 行

JC
49
字号

/*
 *  import stdlib
 *
 *  This is a rudimentary native typelib that implements some useful global functions.
 *  To use a native typelib, it must be registered to the JIL virtual machine.
 *  Then we can conveniently import the functions implemented in the typelib here.
 */

import stdlib;
import math;

/*
 *  function main
 *  test native typelibs
 */

function string main()
{
    test_stdlib();

    return "";
}

/*
 *  function test_stdlib
 *  test static functions of the native typelib stdlib
 */

function test_stdlib()
{
    stdlib::Print( "Hello, this is test_stdlib()!\n\n" );

    stdlib::Printf( "Rand() returns %g\n", stdlib::Rand() );
    stdlib::Printf( "GetTicks() returns %d\n", stdlib::GetTicks() );
    stdlib::Printf( "pow(2, 3) returns %g\n", math::pow(2,3) );

    stdlib::Print( "\nPlease enter something: " );
    string input = stdlib::GetString();
    stdlib::Printf( "You entered: '%s'\n", input );

    stdlib::Print ( "Please enter a number: ");
    input = stdlib::GetString();
    stdlib::Printf( "Your input as long: %d\n", stdlib::Atol(input) );
    stdlib::Printf( "Your input as float: %g\n", stdlib::Atof(input) );

    stdlib::Print( "\nBye!\n\n");
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?