This project is read-only.

Getting Started

Since bGui is not very advanced yet, I can only give you a basic gist of how to use it, but I will try to go into as much detail as I can.

So let's get started!

You're going to want to have:
  • A windows machine
  • .NET Framework 4.0 (
  • Your favorite text editor (something nice for batch; most people just use notepad)
  • The latest version of bGui (head over to source code and clone the repository, I have built the executable and put it in the 'bin' folder)

Alright, so let's start this batch file just like any other:
	@echo off

Here's what this line does in a batch file:
  1. The '@' symbol makes sure that when this line is run, it does not show in the command prompt. For example, instead of:
	@echo Hello, World!
	Hello, World!

We should see:
	Hello, World!

For bGui scripts at the moment, the only echo is on the first two lines; since all others must be run through bGui. In a bGui script, the real initialization looks like this:
	bgui init %0
	exit /b

When this batch file is run, it will call bGui to initiliaze and pass on the location of this batch file (%0), then it will exit to it's caller. Simple enough? Thought so.

Now, since bGui is going to act as an interpreter when called, it needs an entry point to start running code from. In batch, entry points, exit points, and functions are all used through labels. Our entry point label is going to be 'bgui_init'. So now our batch file looks like this:
	@echo off
	bgui init %0
	exit /b

	rem ... future code ...

Syntax of bGui

  • The way bGui works is it waits for you to address something. First, you must address bGui itself. This can be done through either '@' or 'bgui'. It is like running a command.
	rem below, we are addressing bgui and not passing any arguments

  • Next, we want to address something inside of bgui, such as the program. To do this, we start with a '-' followed by the name of what we are addressing.
	rem below we address the program
	@ -program

	rem below we address 'form1'
	@ -form1

  • Now that we have specified what we are addressing, we must specify an action. Let's add a control named 'myControl' to a form named 'form1'.
	rem add 'myControl' to 'form1'
	@ -form1 addctl {"Name": "myControl"}

  • The last little bit, which was shown above, is a JSON string, specifying our arguments and data. For example, above we needed to tell 'form1' the name of the control we were adding, so we used the 'Name' property.

Creating a Form

Programs made in .NET run on object known as forms, these are the same objects we will use in place of windows. Let's create our first form!
	@ -program addform { "Name": "form1", ".Location": "20,20", ".Size": "200x100", ".Text": "MyFirstApp" }

If you read the bgui syntax like you should have, then you know that above we have addressed the program and asked it to add a form whose name we have set to 'form1'. From here on, everytime we need to reference our created form, we will use 'form1'.

When creating the form, we gave the JSON object 4 properties. Three of these, started with a '.'; the reason for this is, any property that starts with a '.' will be interpreted by bGui as a property of 'Name'. In this case, the 'Name' is 'form1', so the 'Location' and 'Size' properties belong to 'form1'.

Displaying the Form

There are two ways to display your form:
  1. Form1.Show()
	@ -form1 {"Method":"Show"}

As you can see, here we are addressing 'form1' but not passing an action. This is alright because in this case, bGui will try setting the properties of the object, or try running 'Method' on the object. In this case, we wish to run 'Show' on the object to get it to display itself. When we call this line, what will happen is that 'form1' will show, but only until your batch file hits end of file. This method is for users who want to do other tasks while their form is showing.
  1. Application.Run()
	@ -form1 {"Method":"Run"}

This method differs from the other one, because it will display the form until the user quits it. While the form is being displayed, your script will halt, and will only continue AFTER the form exits.

Creating a new control

Creating a new control, takes two easy steps.
  1. Creating the actual control
First, we want to create the actual control. To do this, we address the program and give the action 'newctl'. From here, we give the two required properties 'Name' and 'Type', both are self-explanitory. All other properties are to be properties of the control. Let's create a sample label to display 'Hia!':
	@ -program newctl {"Name": "lblOne", "Type": "Label", ".Text": "Hia!"}

  1. Appending to a parent
Now that we have our control, we need a parent container for it. Let's add it to 'form1':
	@ -form1 addctl {"Name": "lblOne"}

Done! You are ready to make your first 'Hello, World!' program in bGui

Last edited Oct 27, 2012 at 6:19 PM by KarimSa, version 2


No comments yet.