From: Ivan Denisov Date: Mon, 9 May 2016 08:38:11 +0000 (+0700) Subject: console example improved X-Git-Url: https://deadsoftware.ru/gitweb?p=bbcp.git;a=commitdiff_plain;h=61a7b6381a456c7554f7688c7cdad4c6c70d1091 console example improved --- diff --git a/examples/console/README b/examples/console/README new file mode 100755 index 0000000..852c2b5 --- /dev/null +++ b/examples/console/README @@ -0,0 +1,22 @@ +Example to demonstrate ConsCompiler and ConsLog. + +ConsCompiler allows to compile sources stored in "txt" format. +ConsLog provides realisation for the Log abstract interface. + +Author of the example: Ivan Denisov, denisov@molpit.org + +Installation and demonstration + +1. Prepare Interp version of BlackBox in "Linux_Interp" folder: + ./switch-target `uname -s` Interp + ./build + ./export ../Linux_Interp + +2. Compile this example: + cd ../examples/console + echo "ConsCompiler.Compile('System/Mod', 'Init.txt')" | ./runc + +3. For demonstration run: + ./runc 123 123 + +Output will contain: "Summ: 246.0". diff --git a/examples/console/System/Mod/Init.odc b/examples/console/System/Mod/Init.odc deleted file mode 100644 index f32fe06..0000000 Binary files a/examples/console/System/Mod/Init.odc and /dev/null differ diff --git a/examples/console/System/Mod/Init.txt b/examples/console/System/Mod/Init.txt new file mode 100644 index 0000000..190d9df --- /dev/null +++ b/examples/console/System/Mod/Init.txt @@ -0,0 +1,39 @@ +MODULE Init; + + IMPORT + Kernel, + HostConsole (* Console.SetHook *) , + + HostFonts (* Fonts.SetHook; required for Texts *), + HostWindows (* Windows.SetHook *), + HostDates (* Dates.SetHook *), + HostDialog (* Dialog.SetShowHook *), + StdInterpreter (* Dialog.SetCallHook *) , + StdDialog (* Views.SetViewHook *), + + Log, ConsLog, (* Log.Hook *) + Strings, + Converters (* .odc *), + Dialog; + + PROCEDURE Init; + VAR + c1, c2, res: INTEGER; a, b: REAL; + BEGIN + IF Kernel.bootInfo.argc = 3 THEN + Strings.StringToReal(Kernel.bootInfo.argv[1]$, a, c1); + Strings.StringToReal(Kernel.bootInfo.argv[2]$, b, c2); + IF (c1 = 0) & (c2 = 0) THEN + Log.String("Summ: "); Log.Real(a + b); Log.Ln + ELSE + Log.String("The arguments should be in the form of real: 13123.556"); Log.Ln + END + ELSE + Log.String("Example of simple console application based on BlackBox Component Builder."); Log.Ln; + Log.String("You can pass two arguments and sum of them will be returned."); Log.Ln + END + END Init; + +BEGIN + Init +END Init. \ No newline at end of file diff --git a/examples/console/run-dev b/examples/console/run-dev deleted file mode 100755 index 50874c1..0000000 --- a/examples/console/run-dev +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# fix Ubuntu-specific problems: -unset UBUNTU_MENUPROXY -unset GTK_MODULES -export LIBOVERLAY_SCROLLBAR=0 -mv Code Code_ -env \ - BB_PRIMARY_DIR="../../BlackBox" BB_SECONDARY_DIR="$PWD" \ -../../BlackBox/blackbox