1. Home
  2. /
  3. Gambas
  4. /
  5. Shopping Cart

Shopping Cart - Gambas Typing CST Test

Loading…

Shopping Cart — Gambas Code

Adds and removes items in a shopping cart with total cost.

DIM cart AS NEW Collection
DIM prices AS NEW Collection

PROCEDURE addItem(item AS String, price AS Integer)
	cart.Add(item)
	prices.Add(price)
	PRINT "Cart: "; cart
	PRINT "Total: "; prices.Sum
END PROCEDURE

PROCEDURE removeItem(index AS Integer)
	cart.RemoveAt(index)
	prices.RemoveAt(index)
	PRINT "Cart: "; cart
	PRINT "Total: "; prices.Sum
END PROCEDURE

' Simulate actions
addItem("Apple", 2)
addItem("Banana", 3)
removeItem(0)

Gambas Language Guide

Gambas is a free, object-oriented programming language and development environment based on BASIC, designed primarily for Linux. It allows rapid development of graphical, database, and console applications, with a visual IDE similar to Visual Basic.

Primary Use Cases

  • ▸Developing Linux GUI applications
  • ▸Rapid prototyping for desktop software
  • ▸Database applications with MySQL, PostgreSQL, or SQLite
  • ▸Educational purposes for learning programming
  • ▸Small utility and productivity tools on Linux

Notable Features

  • ▸Visual IDE with drag-and-drop form designer
  • ▸Object-oriented extensions to BASIC
  • ▸Database and SQL support
  • ▸Multimedia and networking libraries
  • ▸Cross-platform support via Linux and some BSDs

Origin & Creator

Created by Benoît Minisini in 1999 as an open-source alternative to Visual Basic for Linux.

Industrial Note

Gambas is primarily used for rapid prototyping, educational projects, and Linux desktop applications where cross-platform or Windows compatibility is not required.

Quick Explain

  • ▸Gambas extends BASIC with object-oriented features and a rich set of libraries.
  • ▸It includes an integrated development environment (IDE) with a form designer, debugger, and code editor.
  • ▸Gambas supports GUI applications, database integration, networking, and multimedia on Linux desktops.

Core Features

  • ▸BASIC-like syntax with modern enhancements
  • ▸Classes, modules, and objects
  • ▸Signals and slots for event-driven programming
  • ▸Automatic memory management
  • ▸Integrated debugger and GUI designer

Learning Path

  • ▸Learn BASIC syntax
  • ▸Practice Gambas console applications
  • ▸Explore GUI development with forms
  • ▸Connect applications to a database
  • ▸Build complete desktop projects

Practical Examples

  • ▸Creating a simple GUI calculator
  • ▸Developing a database CRUD application
  • ▸Building an event-driven form application
  • ▸Networking with sockets in Gambas
  • ▸Multimedia playback or image processing

Comparisons

  • ▸Similar in syntax to Visual Basic
  • ▸Slower than compiled languages like C++
  • ▸Smaller ecosystem than Python or Java
  • ▸Best suited for Linux desktops rather than cross-platform apps
  • ▸Offers rapid development with a full IDE

Strengths

  • ▸Rapid development for Linux desktop applications
  • ▸Intuitive syntax similar to Visual Basic
  • ▸Built-in IDE with GUI designer
  • ▸Supports modern object-oriented programming
  • ▸Active open-source community with extensions

Limitations

  • ▸Primarily Linux-focused, limited Windows/Mac support
  • ▸Smaller ecosystem compared to mainstream languages
  • ▸Less suitable for performance-critical applications
  • ▸Limited industrial adoption
  • ▸Relatively smaller community and documentation

When NOT to Use

  • ▸High-performance or large-scale applications
  • ▸Cross-platform development beyond Linux
  • ▸Mobile or web development
  • ▸Enterprise-grade software requiring heavy support
  • ▸Projects needing large community support

Cheat Sheet

  • ▸PRINT 'Hello' - output text
  • ▸DIM x AS Integer - declare variable
  • ▸SUB MySub() ... END - define subroutine
  • ▸CLASS MyClass ... END - define class
  • ▸PUBLIC / PRIVATE - visibility modifiers

FAQ

  • ▸Is Gambas free?
  • ▸Yes, licensed under the GPL.
  • ▸Can Gambas run on Windows or macOS?
  • ▸Primarily Linux, limited support on other platforms.
  • ▸Is Gambas object-oriented?
  • ▸Yes, with classes, modules, and inheritance.
  • ▸Does Gambas support databases?
  • ▸Yes, MySQL, PostgreSQL, SQLite, and ODBC connections.
  • ▸Can Gambas create GUI applications?
  • ▸Yes, using the integrated form designer in the IDE.

30-Day Skill Plan

  • ▸Week 1: Gambas syntax and console programs
  • ▸Week 2: GUI design and event handling
  • ▸Week 3: Object-oriented programming with classes and modules
  • ▸Week 4: Database connectivity and queries
  • ▸Week 5: Complete GUI projects and testing

Final Summary

  • ▸Gambas is a Linux-focused, object-oriented BASIC language and IDE.
  • ▸Ideal for rapid development of GUI and database applications.
  • ▸Supports modular programming with classes and modules.
  • ▸Includes a visual form designer, debugger, and runtime environment.
  • ▸Best suited for educational, prototyping, or small Linux desktop applications.

Project Structure

  • ▸Forms/ - GUI form files
  • ▸Classes/ - object-oriented code
  • ▸Modules/ - reusable code modules
  • ▸Resources/ - images, icons, and data files
  • ▸Config/ - project settings and metadata

Monetization

  • ▸Distribute Linux desktop apps
  • ▸Educational and training software
  • ▸Internal company tools
  • ▸Open-source community contributions
  • ▸Consulting and rapid prototyping services

Productivity Tips

  • ▸Use IDE shortcuts for rapid coding
  • ▸Design GUI forms visually
  • ▸Reuse modules for repeated functionality
  • ▸Leverage database connectors and libraries
  • ▸Regularly backup projects and resources

Basic Concepts

  • ▸Variables and basic data types (Integer, String, Boolean, Array)
  • ▸Subroutines and functions
  • ▸Classes, modules, and objects
  • ▸Event handling with signals and slots
  • ▸Database connections and queries

Official Docs

  • ▸Gambas official website and wiki
  • ▸Gambas 3 reference manuals
  • ▸Community tutorials and guides

More Gambas Typing Exercises

Gambas Counter and Theme ToggleGambas Random Number GeneratorGambas Todo ListGambas Dice RollerGambas Countdown TimerGambas Prime CheckerGambas Temperature ConverterGambas Name GreetingGambas Stopwatch

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher