db9025f3a3
- C runtime: bux_float_to_string() for float64 → String conversion
- String.bux: add String_FromFloat, extern decl for bux_float_to_string
- library/std/Fmt.bux: Fmt_Fmt1, Fmt_Fmt2, Fmt_Fmt3, Fmt_FmtInt, Fmt_FmtInt2,
Fmt_FmtFloat, Fmt_FmtBool — positional {0}, {1}, {2} placeholders
- Refactor examples to use Fmt:
factorial.bux, fibonacci.bux, process.bux, os_time.bux
25 lines
836 B
Plaintext
25 lines
836 B
Plaintext
// Os & Time - System and time utilities
|
|
import Std::Io::{PrintLine};
|
|
import Std::Os::{Os_ArgsCount, Os_Args, Os_GetEnv, Os_GetCwd};
|
|
import Std::Time::{Time_NowMs, Time_SleepMs};
|
|
import Std::Fmt::{Fmt_Fmt1, Fmt_FmtInt};
|
|
|
|
func Main() -> int {
|
|
PrintLine("=== OS Demo ===");
|
|
PrintLine(Fmt_Fmt1("Current directory: {0}", Os_GetCwd()));
|
|
PrintLine(Fmt_FmtInt("Command-line args: {0}", Os_ArgsCount() as int64));
|
|
PrintLine(Fmt_Fmt1("HOME env: {0}", Os_GetEnv("HOME")));
|
|
|
|
PrintLine("\n=== Time Demo ===");
|
|
let start: int64 = Time_NowMs();
|
|
PrintLine(Fmt_FmtInt("Start: {0} ms", start));
|
|
PrintLine("Sleeping 150ms...");
|
|
Time_SleepMs(150);
|
|
|
|
let end: int64 = Time_NowMs();
|
|
PrintLine(Fmt_FmtInt("End: {0} ms", end));
|
|
PrintLine(Fmt_FmtInt("Elapsed: {0} ms", end - start));
|
|
|
|
return 0;
|
|
}
|