BASIC256.nsi 0000664 0001750 0001750 00000011677 11675357462 011025 0 ustar jim jim ; BASIC256.nsi
; Modification History
; date...... programmer... description...
; 2008-09-01 j.m.reneau original coding
!include nsDialogs.nsh
Var VERSION
Var VERSIONDATE
var customDialog
var customLabel0
var customLabel1
var customImage
var customImageHandle
Function .onInit
StrCpy $VERSION "0.9.6.66"
StrCpy $VERSIONDATE "2011-07-06"
FunctionEnd
Function customPage
nsDialogs::Create /NOUNLOAD 1018
Pop $customDialog
${If} $customDialog == error
Abort
${EndIf}
${NSD_CreateBitmap} 0 0 100% 100% ""
Pop $customImage
${NSD_SetImage} $customImage resources\images\basic256.bmp $customImageHandle
${NSD_CreateLabel} 50 0 80% 10% "BASIC256 $VERSION ($VERSIONDATE)"
Pop $customLabel0
${NSD_CreateLabel} 0 50 100% 80% "This installer will load BASIC256. Previous versions will be overwritten and any saved files will be preserved."
Pop $customLabel1
nsDialogs::Show
FunctionEnd
; The name of the installer
Name "BASIC256 $VERSION ($VERSIONDATE)"
; The file to write
OutFile "BASIC256-$VERSION_Win32_Install.exe"
; The default installation directory
InstallDir $PROGRAMFILES\BASIC256
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\BASIC256" "Install_Dir"
; Request application privileges for Windows Vista
RequestExecutionLevel admin
InstType "Full"
InstType "Minimal"
;--------------------------------
; Pages
Page custom customPage "" ": BASIC256 Welcome"
Page license
LicenseData "license.txt"
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; The stuff to install
Section "BASIC256"
SectionIn 1 2 RO
SetOutPath $INSTDIR
File .\release\BASIC256.exe
File .\release\libgcc_s_dw2-1.dll
File .\release\mingwm10.dll
File .\release\phonon4.dll
File .\release\QtCore4.dll
File .\release\QtGui4.dll
File .\release\sqlite3.dll
File .\release\inpout32.dll
File ChangeLog
File CONTRIBUTORS
File license.txt
SetOutPath $INSTDIR\Translations
File .\Translations\*.qm
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\BASIC256 "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASIC256" "DisplayName" "BASIC-256"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASIC256" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASIC256" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASIC256" "NoRepair" 1
WriteUninstaller "uninstall.exe"
SectionEnd
; Start Menu Shrtcuts (can be disabled by the user)
Section "Start Menu Shortcuts"
SectionIn 1
SetOutPath $INSTDIR
CreateDirectory "$SMPROGRAMS\BASIC256"
CreateShortCut "$SMPROGRAMS\BASIC256\BASIC256.lnk" "$INSTDIR\BASIC256.exe" "" "$INSTDIR\BASIC256.exe" 0
CreateShortCut "$SMPROGRAMS\BASIC256\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
SectionEnd
; Offline Help (can be disabled by the user for each language)
SectionGroup "Off-line Help and Documentation"
Section "English (en)"
SectionIn 1
SetOutPath $INSTDIR\help\en
File /x ".svn" .\help\en\*.*
SectionEnd
Section "Russian (ru)"
SectionIn 1
SetOutPath $INSTDIR\help\ru
File /x ".svn" .\help\ru\*.*
SectionEnd
Section "Spanish (es)"
SectionIn 1
SetOutPath $INSTDIR\help\es
File /x ".svn" .\help\es\*.*
SectionEnd
Section "French (fr)"
SectionIn 1
SetOutPath $INSTDIR\help\fr
File /x ".svn" .\help\fr\*.*
SectionEnd
Section "German (de)"
SectionIn 1
SetOutPath $INSTDIR\help\de
File /x ".svn" .\help\de\*.*
SectionEnd
SectionGroupEnd
; Examples (can be disabled by the user)
Section "Example Programs"
SectionIn 1
SetOutPath $INSTDIR
File /r /x ".svn" Examples
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BASIC256"
DeleteRegKey HKLM SOFTWARE\BASIC256
; Remove files and uninstaller
Delete $INSTDIR\BASIC256.exe
Delete $INSTDIR\libgcc_s_dw2-1.dll
Delete $INSTDIR\mingwm10.dll
Delete $INSTDIR\phonon4.dll
Delete $INSTDIR\QtCore4.dll
Delete $INSTDIR\QtGui4.dll
Delete $INSTDIR\sqlite3.dll
Delete $INSTDIR\inpout32.dll
Delete $INSTDIR\ChangeLog
Delete $INSTDIR\CONTRIBUTORS
Delete $INSTDIR\license.txt
RMDir /r $INSTDIR\Examples
RMDir /r $INSTDIR\help
RMDir /r $INSTDIR\Translations
Delete $INSTDIR\uninstall.exe
; Remove shortcuts, if any
Delete "$SMPROGRAMS\BASIC256\*.*"
; Remove directories used
RMDir "$SMPROGRAMS\BASIC256"
RMDir "$INSTDIR"
SectionEnd
BASIC256.pro 0000664 0001750 0001750 00000013534 11675357462 011026 0 ustar jim jim ######################################################################
# Automatically generated by qmake (2.00a) Fri Sep 15 19:35:58 2006
######################################################################
TEMPLATE = app
TARGET = BASIC256
DEPENDPATH += .
INCLUDEPATH += .
TMAKE_CXXFLAGS = -g
CONFIG += qt debug_and_release
OBJECTS_DIR = tmp/obj
MOC_DIR = tmp/moc
QT += webkit
RESOURCES += resources/resource.qrc
RC_FILE = resources/basic256.rc
TRANSLATIONS = Translations/basic256_en_US.ts \
Translations/basic256_de.ts \
Translations/basic256_ru_RU.ts \
Translations/basic256_sp.ts \
Translations/basic256_nl.ts
LIBS += -lsqlite3
win32 {
# use SAPI for speech
DEFINES += WIN32
DEFINES += USEQSOUND
LIBS += -lole32 \
-lsapi \
-lws2_32 \
-lwinmm
}
unix:!macx {
## this is the LINUX (unix-non-mac)
DEFINES += LINUX
## TTS Option 1 - ececute 'espak' command to speak
#DEFINES += LINUX_ESPEAK_EXECUTE
## TTS Option 2 - use the espeak library
DEFINES += LINUX_ESPEAK
INCLUDEPATH += /usr/include/espeak
LIBS += -lespeak
## TTS Option 3 - use the flite library
#DEFINES += LINUX_FLITE
#INCLUDEPATH += /usr/include/flite
#LIBS += -lflite_cmu_us_kal16
#LIBS += -lflite
#LIBS += -lflite_cmulex
#LIBS += -lflite_usenglish
LIBS += -lm
## include libraries for SDL audio for wav and sound output
DEFINES += USESDL
LIBS += -lSDL
LIBS += -lSDL_mixer
## rules for make install
examplesDiceFiles.files = ./Examples/dice/*.kbs \
./Examples/dice/*.wav
examplesDiceFiles.path = /usr/share/basic256/Examples/dice
INSTALLS += examplesDiceFiles
examplesImgloadFiles.files = ./Examples/imgload/*.kbs \
./Examples/imgload/*.png \
./Examples/imgload/*.bmp
examplesImgloadFiles.path = /usr/share/basic256/Examples/imgload
INSTALLS += examplesImgloadFiles
examplesNetworkingFiles.files = ./Examples/networking/*.kbs
examplesNetworkingFiles.path = /usr/share/basic256/Examples/networking
INSTALLS += examplesNetworkingFiles
examplesSpritesFiles.files = ./Examples/sprites/*.kbs \
./Examples/sprites/*.wav \
./Examples/sprites/*.png \
./Examples/sprites/*.bmp
examplesSpritesFiles.path = /usr/share/basic256/Examples/sprites
INSTALLS += examplesSpritesFiles
examplesTestingFiles.files = ./Examples/testing/*.kbs
examplesTestingFiles.path = /usr/share/basic256/Examples/testing
INSTALLS += examplesTestingFiles
examplesFiles.files = ./Examples/*.kbs
examplesFiles.path = /usr/share/basic256/Examples
INSTALLS += examplesFiles
transFiles.files = ./Translations/*.qm
transFiles.path = /usr/share/basic256
INSTALLS += transFiles
# EN - english help files
helpENFiles.files = ../doc/help/en/*.html \
./help/en/*.css \
./help/en/*.png \
./help/en/*.jpg
helpENFiles.path = /usr/share/basic256/help/en
INSTALLS += helpENFiles
# DE - german help files
helpDEFiles.files = ../doc/help/de/*.html \
./help/de/*.css \
./help/de/*.png \
./help/de/*.jpg
helpDEFiles.path = /usr/share/basic256/help/de
INSTALLS += helpDEFiles
# ES - spanish help files
helpESFiles.files = ../doc/help/es/*.html \
./help/es/*.css \
./help/es/*.png \
./help/es/*.jpg
helpESFiles.path = /usr/share/basic256/help/es
INSTALLS += helpESFiles
# FR - french help files
helpFRFiles.files = ../doc/help/fr/*.html \
./help/fr/*.css \
./help/fr/*.png \
./help/fr/*.jpg
helpFRFiles.path = /usr/share/basic256/help/fr
INSTALLS += helpFRFiles
# RU - russian help files
helpRUFiles.files = ../doc/help/ru/*.html \
./help/ru/*.css \
./help/ru/*.png \
./help/ru/*.jpg
helpRUFiles.path = /usr/share/basic256/help/ru
INSTALLS += helpRUFiles
# all language translation files
transFiles.files = ./Translations/*.qm
transFiles.path = /usr/share/basic256
INSTALLS += transFiles
# main program executable
target.path = /usr/local/bin
INSTALLS += target
}
macx {
# macintosh
DEFINES += MACX
DEFINES += MACX_SAY
ICON = resources/basic256.icns
LIBS += -L/opt/local/lib
INCLUDEPATH += /opt/local/include
## include libraries for SDL audio for wav and sound output
DEFINES += USESDL
LIBS += -lSDL
LIBS += -lSDL_mixer
}
exists( ./LEX/Makefile ) {
message( Running make for ./LEX/Makefile )
system( make -C ./LEX )
}
else {
error( Couldn't make LEX project - aborting... )
}
# Input
HEADERS += LEX/basicParse.tab.h
HEADERS += BasicEdit.h
HEADERS += Interpreter.h
HEADERS += RunController.h
HEADERS += BasicOutput.h
HEADERS += BasicGraph.h
HEADERS += ErrorCodes.h
HEADERS += GhostButton.h
HEADERS += PauseButton.h
HEADERS += DockWidget.h
HEADERS += BasicWidget.h
HEADERS += ToolBar.h
HEADERS += ViewWidgetIFace.h
HEADERS += MainWindow.h
HEADERS += Variables.h
HEADERS += VariableWin.h
HEADERS += DocumentationWin.h
HEADERS += Version.h
HEADERS += EditSyntaxHighlighter.h
HEADERS += Stack.h
HEADERS += PreferencesWin.h
HEADERS += FindWin.h
HEADERS += ReplaceWin.h
HEADERS += md5.h
SOURCES += LEX/lex.yy.c
SOURCES += LEX/basicParse.tab.c
SOURCES += BasicEdit.cpp
SOURCES += Interpreter.cpp
SOURCES += RunController.cpp
SOURCES += Main.cpp
SOURCES += BasicOutput.cpp
SOURCES += BasicGraph.cpp
SOURCES += GhostButton.cpp
SOURCES += PauseButton.cpp
SOURCES += DockWidget.cpp
SOURCES += BasicWidget.cpp
SOURCES += ToolBar.cpp
SOURCES += ViewWidgetIFace.cpp
SOURCES += MainWindow.cpp
SOURCES += Variables.cpp
SOURCES += VariableWin.cpp
SOURCES += DocumentationWin.cpp
SOURCES += EditSyntaxHighlighter.cpp
SOURCES += Stack.cpp
SOURCES += PreferencesWin.cpp
SOURCES += FindWin.cpp
SOURCES += ReplaceWin.cpp
SOURCES += md5.cpp
basic256.sln 0000664 0001750 0001750 00000001566 11675357462 011264 0 ustar jim jim
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic256", "basic256.vcproj", "{9D316B66-CCFF-4100-9110-B19F86F19490}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9D316B66-CCFF-4100-9110-B19F86F19490}.Debug|Win32.ActiveCfg = Debug|Win32
{9D316B66-CCFF-4100-9110-B19F86F19490}.Debug|Win32.Build.0 = Debug|Win32
{9D316B66-CCFF-4100-9110-B19F86F19490}.Release|Win32.ActiveCfg = Release|Win32
{9D316B66-CCFF-4100-9110-B19F86F19490}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
basic256.vcproj 0000664 0001750 0001750 00000021242 11675357462 011764 0 ustar jim jim
BasicEdit.cpp 0000664 0001750 0001750 00000026003 11707617312 011541 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#include "BasicEdit.h"
#include "Settings.h"
BasicEdit::BasicEdit(QMainWindow *mw)
{
QFont f;
QSettings settings(SETTINGSORG, SETTINGSAPP);
mainwin = mw;
f.setFamily("Sans");
f.setFixedPitch(true);
f.setPointSize(settings.value(SETTINGSFONTSIZE, SETTINGSFONTSIZEDEFAULT).toInt());
setFont(f);
currentMaxLine = 10;
currentLine = 1;
startPos = textCursor().position();
setAcceptRichText(false);
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(cursorMove()));
codeChanged = false;
}
void
BasicEdit::fontSmall()
{
changeFontSize(8);
}
void
BasicEdit::fontMedium()
{
changeFontSize(10);
}
void
BasicEdit::fontLarge()
{
changeFontSize(12);
}
void
BasicEdit::fontHuge()
{
changeFontSize(15);
}
void
BasicEdit::changeFontSize(unsigned int pointSize)
{
QFont f;
f.setFamily("Sans");
f.setFixedPitch(true);
f.setPointSize(pointSize);
setFont(f);
QSettings settings(SETTINGSORG, SETTINGSAPP);
settings.setValue(SETTINGSFONTSIZE, pointSize);
}
void
BasicEdit::cursorMove()
{
QTextCursor t(textCursor());
// get current column
int col = t.position();
t.movePosition(QTextCursor::StartOfLine);
col = col - t.position() + 1;
t.movePosition(QTextCursor::StartOfBlock);
// get line
int line = 1;
while (t.movePosition(QTextCursor::PreviousBlock))
{
line++;
}
currentLine = line;
//
mainwin->statusBar()->showMessage(tr("Line: ") + QString::number(currentLine) + tr(" Column: ") + QString::number(col));
}
void
BasicEdit::highlightLine(int hline)
{
QTextCursor t(textCursor());
t.setPosition(0);
int line = 1;
while (line < hline)
{
t.movePosition(QTextCursor::NextBlock);
line++;
}
t.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor, 1);
setTextCursor(t);
}
void
BasicEdit::goToLine(int newLine)
{
QTextCursor t(textCursor());
t.setPosition(0);
int line = 1;
while (line < newLine && t.movePosition(QTextCursor::NextBlock))
{
line++;
}
setTextCursor(t);
setFocus();
}
void
BasicEdit::keyPressEvent(QKeyEvent *e)
{
e->accept();
codeChanged = true;
QTextEdit::keyPressEvent(e);
}
void
BasicEdit::newProgram()
{
bool donew = true;
if (codeChanged) {
QMessageBox msgBox;
msgBox.setText(tr("New Program?"));
msgBox.setInformativeText(tr("Are you sure you want to completely clear this program and start a new one?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
donew = (msgBox.exec() == QMessageBox::Yes);
}
if (donew)
{
clear();
mainwin->setWindowTitle(tr("Untitled - BASIC-256"));
filename = "";
codeChanged = false;
}
}
void
BasicEdit::saveProgram()
{
if (filename == "")
{
filename = QFileDialog::getSaveFileName(this, tr("Save file as"), ".", tr("BASIC-256 File ") + "(*.kbs);;" + tr("Any File ") + "(*.*)");
}
if (filename != "")
{
QRegExp rx("\\.[^\\/]*$");
if (rx.indexIn(filename) == -1)
{
filename += ".kbs";
}
QFile f(filename);
bool dooverwrite = true;
if (f.exists()) {
QMessageBox msgBox;
msgBox.setText(tr("The file ") + filename + tr(" already exists."));
msgBox.setInformativeText(tr("Do you want to overwrite?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
dooverwrite = (msgBox.exec() == QMessageBox::Yes);
}
if (dooverwrite) {
f.open(QIODevice::WriteOnly | QIODevice::Truncate);
f.write(this->document()->toPlainText().toUtf8());
f.close();
QFileInfo fi(f);
mainwin->setWindowTitle(fi.fileName() + tr(" - BASIC-256"));
QDir::setCurrent(fi.absolutePath());
codeChanged = false;
addFileToRecentList(filename);
}
}
}
void BasicEdit::addFileToRecentList(QString fn) {
// keep list of recently open or saved files
// put file name at position 0 on list
QSettings settings(SETTINGSORG, SETTINGSAPP);
settings.beginGroup(SETTINGSGROUPHIST);
// if program is at top then do nothing
if (settings.value(QString::number(0), "").toString() != fn) {
// find end of scootdown
int e;
for(e=1; e=1; i--) {
settings.setValue(QString::number(i), settings.value(QString::number(i-1), ""));
}
settings.setValue(QString::number(0), fn);
}
settings.endGroup();
// print out for debugging
//settings.beginGroup(SETTINGSGROUPHIST);
//for (int i=0; isetPlainText(QString::fromUtf8(ba.data()));
f.close();
filename = s;
QFileInfo fi(f);
mainwin->setWindowTitle(fi.fileName() + tr(" - BASIC-256"));
QDir::setCurrent(fi.absolutePath());
codeChanged = false;
addFileToRecentList(s);
}
}
}
void BasicEdit::slotPrint()
{
QTextDocument *document = this->document();
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(QObject::tr("Print Code"));
if (dialog->exec() == QDialog::Accepted)
{
if ((printer.printerState() != QPrinter::Error) && (printer.printerState() != QPrinter::Aborted))
{
document->print(&printer);
}
else
{
QMessageBox::warning(this, QObject::tr("Print Error"), QObject::tr("Unable to carry out printing.\nPlease check your printer settings."));
}
}
}
void BasicEdit::beautifyProgram()
{
QString program;
QStringList lines;
const int TAB = 3;
int indent = 0;
bool indentThisLine = true;
bool increaseIndent = false;
bool decreaseIndent = false;
program = this->document()->toPlainText();
lines = program.split(QRegExp("\\n"));
for (int i = 0; i < lines.size(); i++) {
QString line = lines.at(i);
line = line.trimmed();
if (line.contains(QRegExp("^\\S+[:]"))) {
// label - one line no indent
indentThisLine = false;
} else if (line.contains(QRegExp("^[Ff][Oo][Rr]\\s"))) {
// for - indent next (block of code)
increaseIndent = true;
} else if (line.contains(QRegExp("^[Nn][Ee][Xx][Tt]\\s"))) {
// next - come out of block - reduce indent
decreaseIndent = true;
} else if (line.contains(QRegExp("^[Ii][Ff]\\s.+\\s[Tt][Hh][Ee][Nn]$"))) {
// if/then (NOTHING FOLLOWING) - indent next (block of code)
increaseIndent = true;
} else if (line.contains(QRegExp("^[Ee][Ll][Ss][Ee]$"))) {
// else - come out of block and start new block
decreaseIndent = true;
increaseIndent = true;
} else if (line.contains(QRegExp("^[Ee][Nn][Dd]\\s*[Ii][Ff]$"))) {
// end if - come out of block - reduce indent
decreaseIndent = true;
} else if (line.contains(QRegExp("^[Ww][Hh][Ii][Ll][Ee]\\s"))) {
// while - indent next (block of code)
increaseIndent = true;
} else if (line.contains(QRegExp("^[Ee][Nn][Dd]\\s*[Ww][Hh][Ii][Ll][Ee]$"))) {
// endwhile - come out of block
decreaseIndent = true;
} else if (line.contains(QRegExp("^[Dd][Oo]$"))) {
// do - indent next (block of code)
increaseIndent = true;
} else if (line.contains(QRegExp("^[Uu][Nn][Tt][Ii][Ll]\\s"))) {
// until - come out of block
decreaseIndent = true;
}
//
if (decreaseIndent) {
indent -= TAB;
if (indent<0) indent=0;
decreaseIndent = false;
}
if (indentThisLine) {
line = QString(indent, QChar(' ')) + line;
} else {
indentThisLine = true;
}
if (increaseIndent) {
indent += TAB;
increaseIndent = false;
}
//
lines.replace(i, line);
}
this->setPlainText(lines.join("\n"));
codeChanged = true;
}
void BasicEdit::findString(QString s, bool reverse, bool casesens)
{
QTextDocument::FindFlags flag;
if (reverse) flag |= QTextDocument::FindBackward;
if (casesens) flag |= QTextDocument::FindCaseSensitively;
if (!find(s, flag)) {
QMessageBox msgBox;
msgBox.setText(tr("String not found."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
}
void BasicEdit::replaceString(QString from, QString to, bool casesens, bool doall)
{
bool doone = true;
QTextDocument::FindFlags flag;
if (casesens) flag |= QTextDocument::FindCaseSensitively;
while (doone) {
if (from.compare(this->textCursor().selectedText(),(casesens ? Qt::CaseSensitive : Qt::CaseInsensitive))!=0) {
if (!find(from, flag)) {
QMessageBox msgBox;
msgBox.setText(tr("Replace completed."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
doall = false;
}
} else {
this->textCursor().clearSelection();
this->textCursor().insertText(to);
codeChanged = true;
}
doone = doall;
}
}
BasicEdit.h 0000664 0001750 0001750 00000003711 11707617315 011212 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#ifndef __BASICEDIT_H
#define __BASICEDIT_H
#include
#include
#include
#include
#include "ViewWidgetIFace.h"
class BasicEdit : public QTextEdit, public ViewWidgetIFace
{
Q_OBJECT;
public:
BasicEdit(QMainWindow *);
void loadFile(QString);
void findString(QString, bool, bool);
void replaceString(QString, QString, bool, bool);
bool codeChanged;
public slots:
void newProgram();
void saveProgram();
void saveAsProgram();
void loadProgram();
void cursorMove();
void goToLine(int);
void highlightLine(int);
void slotPrint();
void beautifyProgram();
void fontSmall();
void fontMedium();
void fontLarge();
void fontHuge();
void loadRecent0();
void loadRecent1();
void loadRecent2();
void loadRecent3();
void loadRecent4();
void loadRecent5();
void loadRecent6();
void loadRecent7();
void loadRecent8();
protected:
void keyPressEvent(QKeyEvent *);
private:
QMainWindow *mainwin;
int currentMaxLine;
int currentLine;
int startPos;
int linePos;
QString filename;
void changeFontSize(unsigned int);
void addFileToRecentList(QString);
void loadRecent(int);
};
#endif
BasicGraph.cpp 0000664 0001750 0001750 00000010141 11675357462 011724 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#include "BasicGraph.h"
#include "MainWindow.h"
extern QMutex keymutex;
extern int currentKey;
BasicGraph::BasicGraph(BasicOutput *o)
{
image = NULL;
resize(GSIZE_INITIAL_WIDTH, GSIZE_INITIAL_HEIGHT);
output = o;
setMinimumSize(gwidth, gheight);
}
void
BasicGraph::resize(int width, int height)
{
if (image != NULL && width == image->width() && height == image->height()) {
return;
}
gwidth = width;
gheight = height;
delete image;
imagedata = new uchar[sizeof(int) * width * height];
image = new QImage(imagedata, width, height, QImage::Format_ARGB32);
image->fill(Qt::color0);
mouseX = 0;
mouseY = 0;
mouseB = 0;
clickX = 0;
clickY = 0;
clickB = 0;
setMouseTracking(true);
}
void
BasicGraph::paintEvent(QPaintEvent *)
{
QPainter p2(this);
gtop = (height() - gheight) / 2;
gleft = (width() - gwidth) / 2;
p2.drawImage(gleft, gtop, *image);
}
void
BasicGraph::keyPressEvent(QKeyEvent *e)
{
e->accept();
keymutex.lock();
currentKey = e->key();
keymutex.unlock();
}
void BasicGraph::mouseMoveEvent(QMouseEvent *e) {
if (e->x() >= (int) gleft && e->x() < (int) (gleft+gwidth) && e->y() >= (int) gtop && e->y() < (int) (gtop+gheight)) {
mouseX = e->x() - gleft;
mouseY = e->y() - gtop;
mouseB = e->buttons();
}
}
void BasicGraph::mouseReleaseEvent(QMouseEvent *e) {
// cascade call to mouse move so we record clicks real time like moves
mouseMoveEvent(e);
}
void BasicGraph::mousePressEvent(QMouseEvent *e) {
if (e->x() >= (int) gleft && e->x() < (int) (gleft+gwidth) && e->y() >= (int) gtop && e->y() < (int) (gtop+gheight)) {
clickX = mouseX = e->x() - gleft;
clickY = mouseY = e->y() - gtop;
clickB = mouseB = e->buttons();
}
setFocus();
}
bool BasicGraph::initActions(QMenu * vMenu, ToolBar * vToolBar)
{
if ((NULL == vMenu) || (NULL == vToolBar))
{
return false;
}
QAction *copyAct = vMenu->addAction(QObject::tr("Copy"));
QAction *printAct = vMenu->addAction(QObject::tr("Print"));
vToolBar->addAction(copyAct);
vToolBar->addAction(printAct);
QObject::connect(copyAct, SIGNAL(triggered()), this, SLOT(slotCopy()));
QObject::connect(printAct, SIGNAL(triggered()), this, SLOT(slotPrint()));
m_usesToolBar = true;
m_usesMenu = true;
return true;
}
void BasicGraph::slotCopy()
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setImage(*image);
}
void BasicGraph::slotPrint()
{
QPrinter printer(QPrinter::HighResolution);
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(QObject::tr("Print Graphics Output"));
if (dialog->exec() == QDialog::Accepted)
{
if ((printer.printerState() != QPrinter::Error) && (printer.printerState() != QPrinter::Aborted))
{
QPainter painter(&printer);
QRect rect = painter.viewport();
QSize size = image->size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(image->rect());
painter.drawImage(0, 0, *image);
}
else
{
QMessageBox::warning(this, QObject::tr("Print Error"), QObject::tr("Unable to carry out printing.\nPlease check your printer settings."));
}
}
}
BasicGraph.h 0000664 0001750 0001750 00000003662 11675357462 011403 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#ifndef __BASICGRAPH_H
#define __BASICGRAPH_H
#include
#include
#include
#include "ViewWidgetIFace.h"
#include "BasicOutput.h"
#define GSIZE_INITIAL_WIDTH 300
#define GSIZE_INITIAL_HEIGHT 300
class BasicGraph : public QWidget, public ViewWidgetIFace
{
Q_OBJECT;
public:
BasicGraph(BasicOutput *);
QImage *image;
bool initActions(QMenu *, ToolBar *);
// used to store current location of mouse
// default value of -1 when no mouse recorded over graphic output
int mouseX;
int mouseY;
int mouseB;
// used to store location of last mouse click
// default value of -1 when no click recorded
int clickX;
int clickY;
int clickB;
public slots:
void resize(int, int);
void slotCopy();
void slotPrint();
protected:
void paintEvent(QPaintEvent *);
void keyPressEvent(QKeyEvent *);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
private:
uchar *imagedata;
BasicOutput *output;
unsigned int gwidth;
unsigned int gheight;
unsigned int gtop; // position of image in basicgraph widget
unsigned int gleft;
};
#endif
BasicOutput.cpp 0000664 0001750 0001750 00000010035 11675357462 012165 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "Settings.h"
#include "BasicOutput.h"
extern QMutex keymutex;
extern int currentKey;
BasicOutput::BasicOutput( ) : QTextEdit ()
{
setFocusPolicy(Qt::StrongFocus);
gettingInput = false;
QSettings settings(SETTINGSORG, SETTINGSAPP);
changeFontSize(settings.value(SETTINGSFONTSIZE, SETTINGSFONTSIZEDEFAULT).toInt());
}
void
BasicOutput::fontSmall()
{
changeFontSize(8);
}
void
BasicOutput::fontMedium()
{
changeFontSize(10);
}
void
BasicOutput::fontLarge()
{
changeFontSize(12);
}
void
BasicOutput::fontHuge()
{
changeFontSize(15);
}
void
BasicOutput::changeFontSize(unsigned int pointSize)
{
QFont f;
f.setFamily("Sans");
f.setFixedPitch(true);
f.setPointSize(pointSize);
setFont(f);
}
void
BasicOutput::getInput()
{
gettingInput = true;
startPos = textCursor().position();
setReadOnly(false);
setFocus();
}
void
BasicOutput::keyPressEvent(QKeyEvent *e)
{
e->accept();
if (!gettingInput)
{
keymutex.lock();
currentKey = e->key();
keymutex.unlock();
//QTextEdit::keyPressEvent(e);
}
else
{
if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter)
{
QTextCursor t(textCursor());
t.setPosition(startPos, QTextCursor::KeepAnchor);
emit(inputEntered(t.selectedText()));
insertPlainText("\n");
gettingInput = false;
setReadOnly(true);
}
else if (e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Left)
{
QTextCursor t(textCursor());
t.movePosition(QTextCursor::PreviousCharacter);
if (t.position() >= startPos)
QTextEdit::keyPressEvent(e);
}
else if (e->key() == Qt::Key_Home || e->key() == Qt::Key_PageUp || e->key() == Qt::Key_Up)
{
QTextCursor t(textCursor());
t.setPosition(startPos);
setTextCursor(t);
}
else
{
QTextEdit::keyPressEvent(e);
}
}
}
bool BasicOutput::initActions(QMenu * vMenu, ToolBar * vToolBar)
{
if ((NULL == vMenu) || (NULL == vToolBar))
{
return false;
}
QAction *copyAct = vMenu->addAction(QObject::tr("Copy"));
QAction *pasteAct = vMenu->addAction(QObject::tr("Paste"));
QAction *printAct = vMenu->addAction(QObject::tr("Print"));
vToolBar->addAction(copyAct);
vToolBar->addAction(pasteAct);
vToolBar->addAction(printAct);
QObject::connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));
QObject::connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));
QObject::connect(printAct, SIGNAL(triggered()), this, SLOT(slotPrint()));
m_usesToolBar = true;
m_usesMenu = true;
return true;
}
void BasicOutput::slotPrint()
{
QTextDocument *document = this->document();
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog(&printer, this);
dialog->setWindowTitle(QObject::tr("Print Text Output"));
if (dialog->exec() == QDialog::Accepted)
{
if ((printer.printerState() != QPrinter::Error) && (printer.printerState() != QPrinter::Aborted))
{
document->print(&printer);
}
else
{
QMessageBox::warning(this, QObject::tr("Print Error"), QObject::tr("Unable to carry out printing.\nPlease check your printer settings."));
}
}
}
BasicOutput.h 0000664 0001750 0001750 00000002673 11675357462 011643 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#ifndef __BASICOUTPUT_H
#define __BASICOUTPUT_H
#include
#include
#include
#include "ViewWidgetIFace.h"
class BasicOutput : public QTextEdit, public ViewWidgetIFace
{
Q_OBJECT;
public:
BasicOutput();
char *inputString;
void inputStart();
virtual bool initActions(QMenu *, ToolBar *);
public slots:
void getInput();
void slotPrint();
void fontSmall();
void fontMedium();
void fontLarge();
void fontHuge();
signals:
void inputEntered(QString);
protected:
void keyPressEvent(QKeyEvent *);
private:
int startPos;
bool gettingInput;
void changeFontSize(unsigned int);
};
#endif
BasicWidget.cpp 0000664 0001750 0001750 00000004355 11675357462 012120 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#include
#include "ToolBar.h"
#include "ViewWidgetIFace.h"
#include "BasicWidget.h"
BasicWidget::BasicWidget(const QString & title, QWidget * parent, Qt::WindowFlags f)
: QWidget(parent, f)
, m_viewWidget(NULL)
, m_toolBar(NULL)
, m_menu(NULL)
{
m_toolBar = new ToolBar();
m_menu = new QMenu(title);
m_layout = new QVBoxLayout();
setLayout(m_layout);
}
BasicWidget::~BasicWidget()
{
if (NULL != m_toolBar)
{
delete m_toolBar;
m_toolBar = NULL;
}
}
bool BasicWidget::setViewWidget(QWidget * view)
{
if (NULL == view)
{
return false;
}
m_viewWidget = dynamic_cast< ViewWidgetIFace * >(view);
if (NULL != m_viewWidget)
{
if (m_viewWidget->initActions(m_menu, m_toolBar))
{
if (!m_viewWidget->usesToolBar())
{
delete m_toolBar;
m_toolBar = NULL;
}
else
{
m_layout->addWidget(m_toolBar);
}
if (!m_viewWidget->usesMenu())
{
delete m_menu;
m_menu = NULL;
}
}
m_layout->addWidget(view, 1);
return true;
}
return false;
}
void BasicWidget::slotShowToolBar(const bool vShow)
{
if (NULL == m_toolBar)
return;
m_toolBar->setShown(vShow);
}
bool BasicWidget::usesToolBar()
{
if (NULL != m_viewWidget)
{
return m_viewWidget->usesToolBar();
}
return false;
}
bool BasicWidget::usesMenu()
{
if (NULL != m_viewWidget)
{
return m_viewWidget->usesMenu();
}
return false;
}
BasicWidget.h 0000664 0001750 0001750 00000002560 11675357462 011561 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#ifndef __BASICWIDGET_H
#define __BASICWIDGET_H
#include
#include
class QMenu;
class ToolBar;
class ViewWidgetIFace;
class BasicWidget : public QWidget
{
Q_OBJECT;
public:
BasicWidget(const QString & title = QString::null, QWidget * parent = 0, Qt::WindowFlags f = 0);
~BasicWidget();
bool setViewWidget(QWidget * view);
bool usesToolBar();
bool usesMenu();
QMenu *getMenu() { return m_menu; }
public slots:
void slotShowToolBar(const bool);
private:
ViewWidgetIFace *m_viewWidget;
ToolBar *m_toolBar;
QMenu *m_menu;
QVBoxLayout *m_layout;
};
#endif
ByteCodes.h 0000664 0001750 0001750 00000017271 11675357462 011262 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
//No argument ops
#define OP_END 0x00
#define OP_NOP 0x01
#define OP_RETURN 0x02
#define OP_CONCAT 0x03
#define OP_EQUAL 0x04
#define OP_NEQUAL 0x05
#define OP_GT 0x06
#define OP_LT 0x07
#define OP_GTE 0x08
#define OP_LTE 0x09
#define OP_AND 0x0a
#define OP_NOT 0x0b
#define OP_OR 0x0c
#define OP_XOR 0x0d
#define OP_INT 0x0e
#define OP_STRING 0x0f
#define OP_ADD 0x10
#define OP_SUB 0x11
#define OP_MUL 0x12
#define OP_DIV 0x13
#define OP_EX 0x14
#define OP_NEGATE 0x15
#define OP_PRINT 0x16
#define OP_PRINTN 0x17
#define OP_INPUT 0x18
#define OP_KEY 0x19
#define OP_PLOT 0x1a
#define OP_RECT 0x1b
#define OP_CIRCLE 0x1c
#define OP_LINE 0x1d
#define OP_REFRESH 0x1e
#define OP_FASTGRAPHICS 0x1f
#define OP_CLS 0x20
#define OP_CLG 0x21
#define OP_GRAPHSIZE 0x22
#define OP_GRAPHWIDTH 0x23
#define OP_GRAPHHEIGHT 0x24
#define OP_SIN 0x28
#define OP_COS 0x29
#define OP_TAN 0x2a
#define OP_RAND 0x2b
#define OP_CEIL 0x2c
#define OP_FLOOR 0x2d
#define OP_ABS 0x2e
#define OP_PAUSE 0x2f
#define OP_POLY 0x30
#define OP_LENGTH 0x31
#define OP_MID 0x32
#define OP_INSTR 0x33
#define OP_INSTR_S 0x34
#define OP_INSTR_SC 0x35
#define OP_INSTRX 0x36
#define OP_INSTRX_S 0x37
#define OP_OPEN 0x38
#define OP_READ 0x39
#define OP_WRITE 0x3a
#define OP_CLOSE 0x3b
#define OP_RESET 0x3c
#define OP_SOUND 0x40
//Int argument ops
#define OP_GOTO 0x41
#define OP_GOSUB 0x42
#define OP_BRANCH 0x43
#define OP_NUMASSIGN 0x45
#define OP_STRINGASSIGN 0x46
#define OP_ARRAYASSIGN 0x47
#define OP_STRARRAYASSIGN 0x48
#define OP_PUSHVAR 0x49
#define OP_PUSHINT 0x4a
#define OP_DEREF 0x4b
#define OP_FOR 0x4c
#define OP_NEXT 0x4d
#define OP_CURRLINE 0x4e
#define OP_DIM 0x4f
#define OP_DIMSTR 0x50
#define OP_ONERROR 0x51
#define OP_EXPLODESTR 0x52
#define OP_EXPLODESTR_C 0x53
#define OP_EXPLODE 0x54
#define OP_EXPLODE_C 0x55
#define OP_EXPLODEXSTR 0x56
#define OP_EXPLODEX 0x57
#define OP_IMPLODE 0x58
//2 Int argument ops
#define OP_ARRAYLISTASSIGN 0x60
#define OP_STRARRAYLISTASSIGN 0x61
//Float argument ops
#define OP_PUSHFLOAT 0x70
//String argument ops
#define OP_PUSHSTRING 0x80
// jmr
#define OP_ASC 0x90
#define OP_CHR 0x91
#define OP_FLOAT 0x92
#define OP_READLINE 0x93
#define OP_WRITELINE 0x94
#define OP_EOF 0x95
#define OP_MOD 0x96
#define OP_YEAR 0x97
#define OP_MONTH 0x98
#define OP_DAY 0x99
#define OP_HOUR 0x9a
#define OP_MINUTE 0x9b
#define OP_SECOND 0x9c
#define OP_SETCOLORRGB 0x9d
#define OP_TEXT 0x9e
#define OP_FONT 0x9f
#define OP_SAY 0xa0
#define OP_WAVPLAY 0xa1
#define OP_WAVSTOP 0xa2
#define OP_SEEK 0xa3
#define OP_SIZE 0xa4
#define OP_EXISTS 0xa5
#define OP_STAMP 0xa6 // stamp with 4 numbers x,y,scale,rotation and an array
#define OP_STAMP_LIST 0xa7 // stamp with x, y, and an immediate list
#define OP_STAMP_S_LIST 0xa8 // stamp with x, y, scale and an immediate list
#define OP_STAMP_SR_LIST 0xa9 // stamp with x, y, scale, and rotation and an immediate list
#define OP_POLY_LIST 0xaa
#define OP_MOUSEX 0xab
#define OP_MOUSEY 0xac
#define OP_MOUSEB 0xad
#define OP_CLICKCLEAR 0xae
#define OP_CLICKX 0xaf
#define OP_CLICKY 0xb0
#define OP_CLICKB 0xb1
#define OP_LEFT 0xb2
#define OP_RIGHT 0xb3
#define OP_UPPER 0xb4
#define OP_LOWER 0xb5
#define OP_ARRAYASSIGN2D 0xb8
#define OP_STRARRAYASSIGN2D 0xb9
#define OP_DEREF2D 0xba
#define OP_SYSTEM 0xbb
#define OP_VOLUME 0xbc
#define OP_SOUND_ARRAY 0xbd
#define OP_SOUND_LIST 0xbe
#define OP_SETCOLORINT 0xbf
#define OP_RGB 0xc0
#define OP_PIXEL 0xc1
#define OP_GETCOLOR 0xc2
#define OP_ASIN 0xc3
#define OP_ACOS 0xc4
#define OP_ATAN 0xc5
#define OP_DEGREES 0xc6
#define OP_RADIANS 0xc7
#define OP_REDIM 0xc8
#define OP_REDIMSTR 0xc9
#define OP_REDIM2D 0xca
#define OP_REDIMSTR2D 0xcb
#define OP_ALEN 0xcd
#define OP_ALENX 0xce
#define OP_ALENY 0xcf
#define OP_INTDIV 0xd0
#define OP_LOG 0xd1
#define OP_LOGTEN 0xd2
#define OP_GETSLICE 0xd3
#define OP_PUTSLICE 0xd4
#define OP_PUTSLICEMASK 0xd5
#define OP_IMGLOAD 0xd6
#define OP_IMGLOAD_S 0xd7
#define OP_IMGLOAD_SR 0xd8
#define OP_SQR 0xd9
#define OP_EXP 0xda
// extended codes
#define OP_EXTENDED_0 0xe0
#define OP_EXTENDED_1 0xe1
#define OP_EXTENDED_2 0xe2
#define OP_EXTENDED_3 0xe3
#define OP_EXTENDED_4 0xe4
#define OP_EXTENDED_5 0xe5
#define OP_EXTENDED_6 0xe6
#define OP_EXTENDED_7 0xe7
#define OP_EXTENDED_8 0xe8
#define OP_EXTENDED_9 0xe9
#define OP_EXTENDED_A 0xea
#define OP_EXTENDED_B 0xeb
#define OP_EXTENDED_C 0xec
#define OP_EXTENDED_D 0xed
#define OP_EXTENDED_E 0xee
#define OP_EXTENDED_F 0xef
// stack manipulation
#define OP_STACKSWAP 0xf0
#define OP_STACKTOPTO2 0xf1
// extended opcodes (second byte)
// first group e0xx
#define OP_SPRITEDIM 0x00
#define OP_SPRITELOAD 0x01
#define OP_SPRITESLICE 0x02
#define OP_SPRITEMOVE 0x03
#define OP_SPRITEHIDE 0x04
#define OP_SPRITESHOW 0x05
#define OP_SPRITECOLLIDE 0x06
#define OP_SPRITEPLACE 0x07
#define OP_SPRITEX 0x08
#define OP_SPRITEY 0x09
#define OP_SPRITEH 0x0a
#define OP_SPRITEW 0x0b
#define OP_SPRITEV 0x0c
#define OP_CHANGEDIR 0x0d
#define OP_CURRENTDIR 0x0e
#define OP_WAVWAIT 0x0f
#define OP_DECIMAL 0x10
#define OP_DBOPEN 0x11
#define OP_DBCLOSE 0x12
#define OP_DBEXECUTE 0x13
#define OP_DBOPENSET 0x14
#define OP_DBCLOSESET 0x15
#define OP_DBROW 0x16
#define OP_DBINT 0x17
#define OP_DBFLOAT 0x18
#define OP_DBSTRING 0x19
#define OP_LASTERROR 0x1a
#define OP_LASTERRORLINE 0x1b
#define OP_LASTERRORMESSAGE 0x1c
#define OP_LASTERROREXTRA 0x1d
#define OP_OFFERROR 0x1e
#define OP_NETLISTEN 0x1f
#define OP_NETCONNECT 0x20
#define OP_NETREAD 0x21
#define OP_NETWRITE 0x22
#define OP_NETCLOSE 0x23
#define OP_NETDATA 0x24
#define OP_NETADDRESS 0x25
#define OP_KILL 0x26
#define OP_MD5 0x27
#define OP_SETSETTING 0x28
#define OP_GETSETTING 0x29
#define OP_PORTIN 0x2a
#define OP_PORTOUT 0x2b
#define OP_BINARYOR 0x2c
#define OP_BINARYAND 0x2d
#define OP_BINARYNOT 0x2e
#define OP_IMGSAVE 0x2f
#define OP_DIR 0x30
#define OP_REPLACE 0x31
#define OP_REPLACE_C 0x32
#define OP_REPLACEX 0x33
#define OP_COUNT 0x34
#define OP_COUNT_C 0x35
#define OP_COUNTX 0x36
#define OP_OSTYPE 0x37
#define OP_MSEC 0x38
#define OP_EDITVISIBLE 0x39
#define OP_GRAPHVISIBLE 0x40
#define OP_OUTPUTVISIBLE 0x41
#define OP_TEXTWIDTH 0x42
ChangeLog 0000664 0001750 0001750 00000067224 11675357462 011005 0 ustar jim jim 2011-08-08 j.m.reneau 0.9.6.68
* added TEXTWIDTH statement to return width of a string i the current font before output to the graphics area
2011-08-07 j.m.reneau 0.9.6.67
* added -r option to command line to switch UI to run only mode
2011-07-01 j.m.reneau 0.9.6.66
* changed inpout32.dll linking to dynamic for Windows port to eliminate the dll hell
* merged in http://patch-tracker.debian.org/patch/series/view/basic256/0.9.6.60-2/04_portable_sound.diff
* fix off-line documentation load on windows - to use the application absolute path to fing help folder
2011-05-01 j.m.reneau 0.9.6.65
* renamed spanish help file to es not sp
2011-03-19 j.m.reneau 0.9.6.65
* Added GRAPHVISIBLE, EDITVISIBLE, and OUTPUTVISIBLE statements to hide sections if the UI from a running program.
2011-03-18 j.m.reneau 0.9.6.64
* Added option to View menu to hide Edit Widget (program source)
2011-03-17 Javier Gonzlez
* new Spanish UI translation
2011-03-05 j.m.reneau 0.9.6.63
* Added replace dialog and refined find dialog
2011-03-04 j.m.reneau 0.9.6.62
* Added find dialog
2011-02-14 j.m.reneau 0.9.6.61
* fixed windows only problem with DIR statement
* restructured and documented the doc tree
* worked on the windows installer to allow for optional install of offline help and examples
2011-02-14 j.m.reneau 0.9.6.60
* added MSEC function to return program running time in milliseconds
2011-01-20 j.m.reneau 0.9.6.59
* added option to use espeak for TTS from shell not as a library
* update documentation in BASIC256.pro and COMPILING.txt
2011-01-07 j.m.reneau 0.9.6.58
* added OSTYPE function to return the type of OS this was compiled
2011-01-06 j.m.reneau 0.9.6.57 (473)
* added IMPLODE to change an array to a string
* updated Russian translation
2011-01-05 j.m.reneau 0.9.6.56 (469)
* added INSTRX() to return position of a Regular Expression
* added REPLACEX() function to find an regular expression and replace with a string
* added COUNTX() function to retuen number of occourances of a regular expression
* added EXPLODEX() function to split a string into a string or numeric array on a regular expression
2011-01-03 j.m.reneau 0.9.6.55 (468)
* allow assignment of indirect list of values {} to redimision an array to the correct size
* added two optional arguments to INSTR() - Start and IgnoreCase
* added Unicode safe string REPLACE() function
* added Unicode safe substring count COUNT() function
* added EXPLODE() function to split a string into a string or numeric array
2011-01-02 j.m.reneau 0.9.6.54 (467)
* added dir() function
2010-12-31 sergey irupin 0.9.6.53 (466)
* add offline help system
* replace About window
* fixed highlighting of keywords
2010-12-13 j.m.reneau 0.9.6.53 (452)
* changed variables object to use a map for storage and not a static array - in preparation for some day handling run levels
2010-12-12 j.m.reneau 0.9.6.52 (451)
* moved variables out of interperter into a new object in preparation for some day adding multiple run levels to handle true functions and subroutines
* also celeaned up several variable related memory leaks
2010-12-10 sergey irupin 0.9.6.51 (449)
* add 2 mathematics functions - sqr()/sqrt(), exp()
2010-11-26 sergey irupin 0.9.6.50 (448)
* icon updates and fixed functions upper() and lower()
2010-11-18 j.m.reneau 0.9.6.49 (443)
* added close of database files if database not closed by program
2010-11-03 j.m.reneau 0.9.6.48 (439)
* removed mutex from say statement - eliminate frezing after speech
2010-10-25 j.m.reneau 0.9.6.47 (438)
* initial MAC port - tested help & preferences
* added Mac Icon
* added logic to save font size as a preference
2010-10-24 j.m.reneau 0.9.6.46 (437)
* initial MAC port - tested sound, say, playwav, database, and networking
2010-10-17 j.m.reneau 0.9.6.45 (435)
* added IMGSAVE statement to save graphics area as a .png or other qt supported file type
2010-10-15 j.m.reneau 0.9.6.44 (434)
* forces locale to "C" so that decimal mark '.' will always work
2010-10-11 j.m.reneau 0.9.6.43 (433)
* fixed seek statement
2010-09-21 j.m.reneau 0.9.6.42
* tested inpout32 with Windows7-x64 and Vista-x32 and changed compiling instructions
2010-09-20 j.m.reneau 0.9.6.41 (431)
* finished and tested PORTIN/PORTOUT statements for parallel port control (WINDOWS ONLY)
* added preference settings to allow or disable PORTIN/PORTOUT statements
* added three new operators &, | and ~ - bitwise and or and not that work with integers
2010-09-19 j.m.reneau 0.9.6.40 (430)
* INCOMPLETE - Code to start adding PORTIN/PORTOUT statementf for parallel port control
2010-09-14 j.m.reneau 0.9.6.39 (429)
* fixed SYSTEM statement to use mutex to wait correctly
* added preference settings to allow or disable system, get/setsetting
2010-09-12 j.m.reneau 0.9.6.38 (428)
* added GETSETTING and SETSETTING for persistant application storage to the registery/config folder
2010-09-12 j.m.reneau 0.9.6.37 (427)
* Created password protected preferences dialog - nothing on it yet except the password
* added MD5 function to return a hex string digest for a string
2010-09-11 j.m.reneau 0.9.6.36 (425)
* added settings to restore IDE and help to size and location when re-opened
* added list of 9 most recently opened or saved items for quick open on file menu
2010-09-08 j.m.reneau 0.9.6.35 (423)
* Added NETADDRESS to return the local IPv4 address as a string
2010-09-06 j.m.reneau 0.9.6.34 (422)
* Added kill statement to delete a file from the file system
2010-08-22 j.m.reneau 0.9.6.33 (421)
* fixed problem with focus effecting "key" statement - if focus was ever lost from
- graphics window - key statement would stop working. added key trap to BasicOutput
- and logic to allow BasicGraph to regain focus
* syntax highliter updated for a few misses commands
2010-08-17 j.m.reneau 0.9.6.32 (419)
* Added net* statements and functions to the syntax highlighter and a new networking example
2010-08-17 j.m.reneau 0.9.6.31 (418)
* fixed linux to compile again after changes in 0.9.6.30
* removed most of the errors from LEX/basicParse.y
2010-08-17 j.m.reneau 0.9.6.30 (416)
* changed all tokens to B256... in lex folder to stop conflicts with windows wtypes.h
* work on porting to winsock (Windows) - have functioning well enough to test
* changed net commands to act like file io commands and allow up to 8 open
- sockets 0-7 with 0 being the default.
2010-08-15 j.m.reneau 0.9.6.29 (416)
* cleaned up socket release (close)
* added NETDATA function to return true if data is waiting to be received
2010-08-13 j.m.reneau 0.9.6.28 (415)
* added first attempt at networking statements
- statements NETLISTEN, NETCONNECT, NETREAD, NETOPEN, and NETCLOSE
* added new networking folder to Examples with a few test programs
* not compiled or tested in Windows yet.
2010-08-09 j.m.reneau 0.9.6.27 (412)
* fixed string comparison problem caused since 0.9.6h
2010-08-05 j.m.reneau 0.9.6z (409)
* Rewrote the error messaging process to allow for error trapping and reporting logic in BASIC code
* added ONERROR label to jump to a subroutine to handle errors
* added LASTERROR, LASTERRORMESSAGE, LASTERRORLINE, and LASTERROREXTRA functions that describe last runtime error
* added OFFERROR statement to restore default error handling - fail on error
* changed parser to allow labels at the begining of any line or on a line by themselves
* added display of column number of cursor in status bar when editing
* added _ as a valid character in a veriable or label name (first letter MUST still be a letter)
2010-08-02 j.m.reneau 0.9.6y
* Added sqLite database processing - dbopen, dbclose, dbsetopen, dbsetclose, and dbexecute statements, also dbint, dbfloat, dbstring, and dbrow functions to manipulate recordsets
2010-07-27 j.m.reneau 0.9.6x
* left alen, alenx, and aleny in lex files when adding 2d and redim of arrays - unused - removed
2010-07-26 j.m.reneau 0.9.6w (405)
* added decimal statemene to define maximum number of decimal places to display
(full precision of a double is still being maintained behind the scenes)
* fixed web site on about box
* added recent new statements to syntax highliter
2010-07-21 j.m.reneau 0.9.6v (403)
* fixed several gramatical errors with file messages - thanks joel
* removed maximum size of graphical output widget
2010-07-13 j.m.reneau 0.9.6u (402)
* fixed wavwait logic for compile under Win32. Also noticed in the QSound documentation
that wavwait will not work under Windows because of a quirk with the library.
* made the graphics and text output so that they may float
2010-07-04 j.m.reneau 0.9.6t
* added new wavwait statement to wait for the currently playing wav to finish
2010-07-02 j.m.reneau 0.9.6s
* totally re-wrote linux sound functionallity to use the SDL library and SDL_mixer. Resolved issued with QSound (requiring NAS) and the /dev/dsp not being released bu the TTS libraries.
2010-06-25 j.m.reneau 0.9.6r
* added currentdir and changedir statements to manage the current folder
* moved documentation to WIKI at doc.basic256.org and changed link in documentwindow.
2010-06-25 j.m.reneau 0.9.6q
* found read statement removed from LEX - readded
* fixed string pointer conversion in readline
* changed sprite move to limit range to 0-graphwidth|graphheight-1
* changed all file io statements to allow for 0-7 files simultaneously - syntax didn't change for single file operations but new filenumber parameter added to allow for multiple files
2010-06-14 j.m.reneau 0.9.6p (393)
* re-wrote the way color "Clear" works
- getcolor and pixel will return a -1 when the drawing color or pixel requested is clear (or after a clg and nothing has been drawn there)
- the CLEAR constant/function now has a value of -1
- all of the drawing commands (point,line,rect,cir,poly,stamp) now will replace pixels with a transparent when color is clear
# added clear of the graphics output area - when initialized to cleanup LINUX display
2010-06-13 j.m.reneau 0.9.6o
* added spritev - visible function
* added spriteslice - extract a sprite from the screen and demo program
* changed sprite to be not visible when created - so that is can be moved and so that it does not change the screen when sliced out.
2010-06-09 j.m.reneau 0.9.6n
* fixed several memory leaks with strings from stack and variable assignments
* added sprites - spritedim, spriteload, spritemove, spriteplace, spritex, spritey, spritew, spriteh, and spritecollide
2010-06-07 j.m.reneau 0.9.6m
* fixed linux compile with lib espeak
* added logic to parser to allow for whitespace before a label - to allow older examples to run
2010-06-01 j.m.reneau 0.9.6l
* fixed help display path when windows installed.
* added getslice, putslice, and imgload into syntax highlighter
* changed imgload from 0.9.6k to place the center of the image at the specified coordinates
* added rotate and scale parameters to imgload like stamp
2010-05-31 j.m.reneau 0.9.6k (377)
* added imgload statement to load a bmp, gif, jpg, or pgn from a file and siaplsy it on the graphics output window
* compiled new ru translation from Sergey
2010-05-25 j.m.reneau 0.9.6j (376)
* added ability to enter integers in code with 0[bB][01] for binary 0[oO][0-7] for octal and 0[xX][0-9a-fA-F] for hexidecimal
2010-05-18 j.m.reneau 0.9.6i (374)
* added dialog to verify overwriting file
* added dialog to verify loading program and loosing changes
* changed new dialog to only appear if unsaved changes are in buffer
* added dialog on close to verify loosing changes (both exit and window close)
* added undo and redo to menu and toolbar for editor
* changed genhelp.list to make all ids and see also links lowercase - for LINUX
2010-05-18 j.m.reneau 0.9.6h (370)
* added search to Documentation Window
2010-05-17 j.m.reneau 0.9.6g (369)
* changed Documentation Window to use WebView to fix the #tags for navigation
2010-05-12 j.m.reneau 0.9.6f (362)
* added error statements to linus sound and speech functions. They are still rough and troublesome.
2010-05-11 j.m.reneau 0.9.6e (361)
* added statements to BASIC256.pro file so qmake would make the "make install" for linux to ease build
2010-05-10 j.m.reneau 0.9.6c (359)
* changes for fontsize
* update Russian translation
2010-05-09 j.m.reneau 0.9.6b (353)
* GetSlice returns a hex string representing a slice (rectangular area) of the screen
* PutSlice will draw the slice. you may defina a transparent color in slice.
2010-05-02 j.m.reneau 0.9.6a (350)
* handle Utf8 strings (drblast)
* rewrite string functions to use unicode characters
* now program save and load in utf8
* compiled RU translation
2010-04-18 j.m.reneau 0.9.5v (329)
* added \ operator for integer division
* added log() and log10() functions
2010-04-15 j.m.reneau 0.9.5t (326)
* Redim an array to change it's size while maintaining it's contents
2010-03-08 j.m.reneau 0.9.5m (318)
* changed color staretemt to accept a single number RGB value r*255^2+g*255+b.
* changed colors to constants that return a color integer
* added rgb function to take color triplet and return color integer
* added getcolor to return the value of the current drawing color
* added pixel to get the color value of a pixel on the graphics output
2010-02-01 j.m.reneau 0.9.5l (316)
* finished linux implementastion of new sound command
2010-01-29 j.m.reneau 0.9.5j (315)
* added cut, copy and paste icons to tool bar
* added option for sound to accept an array or list of frequency and durations. This allows for fast smooth transition when playing multiple tones in a stream. linux logic not tested with this commit.
2010-01-28 j.m.reneau 0.9.5i (312)
* added volume command to control the amplitude of the sound wave out
* changed LINUX TTS to flite engine from espeak. espeak was having problems releasing the /dev/dsp device
* cleaned up syntax high-liter
2010-01-26 j.m.reneau 0.9.5h (311)
* added system command and cleaned up documentation
2010-01-26 j.m.reneau 0.9.5g (310)
* re-wrote say to use libespeak under linux - need to get same change made to windows
* added logic to do the sound command in LINUX by writing a sine wave to /dev/dsp
* update doc.lisp and compiling.txt with info
* changed say command to use Microsoft SAPI instead of running a command line version of espeak. Also changed the Windows version of sound to generate a wave out to the soundcard and only use the system speaker if sound is not available (sound on a laptop)
2010-01-16 j.m.reneau 0.9.5e (308)
* added UPPER and LOWER character functions, cleaned up syntax highlighter
2010-01-15 j.m.reneau 0.9.5c (306)
* added two dimensional arrays to language (dim, reference, assignment, and input without prompt. Still need to add to input with a prompt.
* updated documentation and 15puzzle.kbs example
2010-01-12 j.m.reneau 0.9.5c (303)
* added left and right string functions, documented them
* cleaned up syntax highliter with newer reserved words and fixed string highlight
2009-12-25 j.m.reneau 0.9.4g (296)
* added multi line if/endif and if/else/endif. a;so added while/endwhile loop
0.9.4f
* Asc, Chr, Float, Font, Text
2009-12-21 j.m.reneau 0.9.4e
* added mouse functions - Mouseb, Mousex, Mousey, Clickb, Clickx, Clicky, Clickclear
2009-12-03 j.m.reneau 0.9.4
* added date and time functions - Day, Hour, Minute, Month, Second, Year
* added file functions - Eof, Writeline, Exist, Seek, Size
* added sound and speak functions - Say, WAVplay, WAVstop
2009-11-05 j.m.reneau 0.9.3o
* added STAMP to draw a scaled poly at a position on the graphics display - sort of a simple sprite
* added TRUE and FALSE boolean constant values
* corrected problem with x&y reversing when an indirect list was defined for a POLY
* removed the unused number of points from the syntax of POLY
2009-11-04 j.m.reneau 0.9.3n
* added SIZE, EXISTS, and SEEK for use during file IO
2009-11-02 j.m.reneau 0.9.3m
* rewrite popint/popfloat/popstring in interperter.cpp to return type not a stack value
2009-11-01 j.m.reneau 0.9.3l
* added alternate syntax of input statement to allow a numeric variable or array. If non numeric data is entered a zero will be stored in the variable
* added logic to allow for < > <= >= comparisons of strings
2009-10-31 j.m.reneau 0.9.3k
* added WAVPLAY and WAVSTOP commands to asynchronously play a wav audio file and to stop it
2009-10-29 j.m.reneau 0.9.3j
* added GRAPHHEIGHT and GRAPHIDTH to return the size of the graphics window
* worked on the HTML documentation, added GRAPHSIZE, GRAPHWIDTH, and GRAPHHEIGHT
2009-10-28 j.m.reneau 0.9.3.i
* worked my prior changes into the trunk
2009-10-26 j.m.reneau 0.9.3h
* changed say statement to allow for same arguments (float and string) as print
* changes say to use espeak without a direct path to the exe file. requires espeak in path on windows
2008-09-23 j.m.reneau 0.9.3g
* added SAY statement to call locally installed espeak to tts string - need to re-write for linux and would like to see it use the espeak lib
2008-09-08 j.m.reneau 0.9.3f
* added font "fontname", point, weight and text x, y, "txt" commands to paint text onto the graphics window (TestPrograms/testtextfont.kbs"
2008-09-07
* added logic to yyerror in LEX\basicParse.y to fix syntax error line number problem. If an error was the last token on the line it would report the error on the next line. check yytoken if \n and if it is then report previous line
* added column number to syntax error printing - added count logic to basicParse.l
* fixed rand - it would return values between 0 and 1 with 1 inclusive changed to return almost one but not quite (see TestPrograms/random_one.kbs)
2008-09-05
* changed yacc scriopt for order of operations
* removed imask logic from BasicGraph and Interperter. Was causing refresh and draw errors on fast (dual core win32 xp&vista) boxes
* split version # out of MainWindow into Version.h
2008-09-01
* Added array testing to array input like logic added 2008-08-29
* Added COLOR #,#,# to set colors by rgb
* changed poly to draw filled not just outline
* created NSIS install script for Win32
2008-08-29
* Added Functions asc, chr, float
* Added command readline and writeline to i/o an entire line as a string
* Added boolean flag eof to test if file was at eof
* added % operator for modulo
* added logic to allow for concatenation if float + string or string + float
* combined redudant graphics wait mutex logic in Interperter
* in Interperter added popint, popfloat, popstring to the stack and changed most ops to use these new pops so that type checking could be removed in the op code
* found error in array element assign (string and number) if assigning as an array a non array variable or a non defined variable
* found error in arraylist assign (string and number) if assigning as an array a non array variable or a non defined variable - see uaarray.kbs
* added print statement with no string to go to next line
* added YEAR MONTH DAY HOUD MINUTE SECOND as constants like RAND and PI
2006-12-12 ian larsen
* LEX\basicParse.y: Added sound command.
* LEX\basicParse.l: Added sound command.
* RunController.cpp (playSound): Added sound support.
* Interpreter.cpp (execByteCode): Added sound support.
2006-12-10 ian larsen
* BasicEdit.cpp (newProgram): fixed file overwrite bug when new program saves as last file's name.
* LEX\basicParse.l: Added semicolon as alternate remark command
2006-12-04 ian larsen 0.9.1
* VariableWin.cpp (addVar): Changed variable window to use TreeWidget instead of a list, to allow for showing arrays.
2006-11-28 ian larsen 0.9
* Interpreter.cpp (execByteCode): Changed variable window updates to only occur in debug mode. Otherwise this is a severe performance hit for programs updating many variables in tight loops.
* VariableWin.cpp (clearTable): Added Variable Watch window.
2006-11-26 ian larsen
* MainWindow.cpp (QMainWindow): Added two items to view menu to enable/disable text and graphics output windows.
2006-11-20 ian larsen
* Interpreter.cpp (execByteCode): Merged file ops and changed them to work more simply.
* Changed array printing to print pointer address instead of int, which should fix the 64 bit compile problem.
2006-11-19
* Added file operations "open", "read", "write", "close". The read and write functions work on a token basis. EOF is returned by returning an empty token.
* Added code to test new functions "fileops1.kbs" (and 2 and 3).
2006-11-17
* Added string "length" function and sample code "length.kbs"
* Added alternative spelling for "color" function: "colour"
* Added "poly" function and sample code "polygon.kbs"
2006-11-07 ian larsen 0.8
* LEX\basicParse.y: Fixed rather important memory allocation bug that affected large programs that used lots of if statements.
* Interpreter.cpp (execByteCode): Fixed bug 1589686
2006-11-03 ian larsen
* Interpreter.cpp (compileProgram): Changed the way the interpreter keeps track of line numbers. Now there's a CURRLINE bytecode which is executed every time the line changes. Also added step-by-step debugging.
2006-11-02 ian larsen
* Interpreter.cpp (execByteCode): Printing of floating point instead of integers fixed.
2006-11-01 ian larsen
* Interpreter.cpp (execByteCode): Added OP_LINE, which draws lines.
2006-10-31 ian larsen
* Interpreter.cpp (execByteCode): Added pause command
* BasicEdit.cpp (cursorMove): Added slot to calculate line number when the cursor moves, and display it on the status bar.
2006-10-25 ian larsen 0.7
* Main.cpp (main): Added actions to edit menu. Removed close button on output windows.
2006-10-20 ian larsen 0.6
* Interpreter.cpp: Added internationalization support.
* BasicEdit.cpp: Added internationalization support.
* Main.cpp (main): Added internationalization support.
2006-10-18 ian larsen
* BasicEdit.cpp (BasicEdit): Editor now won't accept rich text, fixing weird font bugs.
* RunController.cpp (saveByteCode): Added saveByteCode function which saves the compiled byte code to a .kbc file.
* Main.cpp (main): Added save byte code function and Advanced menu.
* LEX\basicParse.y: Changed to more dynamic allocation of byteCode to reduce memory footprint for small programs and to prevent memory errors from occurring on 64-bit architectures.
* Interpreter.cpp (execByteCode): Added mathematical functions FLOOR, CEIL, RAND, SIN, COS, TAN, and ABS
Separated initialize from compileProgram to support saving byte code as a file.
2006-10-16 ian larsen 0.5
* Interpreter.cpp (execByteCode): Added and, not, xor, and or operations
* LEX\basicParse.y: Added AND, NOT, XOR, OR
* LEX\basicParse.l: Added floor, ceil, int, str, and rand tokens
* LEX\basicParse.y: Added arrays and string arrays.
* Interpreter.h (struct variable): Added arrays and string arrays.
* Interpreter.cpp (execByteCode): Added arrays and string arrays.
2006-10-11 ian larsen 0.4
* BasicGraph.cpp (keyPressEvent): Added keyPressEvent to set currentKey global variable whenever a key is pressed during run time.
* LEX\basicParse.y: Added KEY keyword as floatexpr
* Interpreter.cpp (execByteCode): Added OP_KEY operation, which gets the last key pressed.
2006-10-09 ian larsen
* LEX\basicParse.y: Added colon as multiple statement separator
2006-10-07 0.3.1
* RunController.cpp (stopRun): Changed to threaded model.
* Interpreter.cpp (execByteCode): Changed to a threaded model.
* BasicOutput.cpp (getInput): Added slot to support threading.
* Interpreter.cpp (execByteCode): Changed from using QPixmaps for graphical output to QImage, which is thread-safe.
2006-10-06 ian larsen 0.3
* Interpreter.cpp (pause): Removed unnecessary pause and unpause functions
* RunController.cpp (pauseResume): Enabled Pause/Resume feature
* PauseButton.h: Created Pause button which changes text based on operation
* Main.cpp (main): Removed Renumber Lines menu option
(main): Pause/Resume button enabled
2006-09-30 ian larsen 0.1
* n sourceforge.net uploaded the first version
COMPILING.txt 0000664 0001750 0001750 00000007036 11675357462 011310 0 ustar jim jim Compiling Instructions and Dependencies - 2011-06-30
LINUX you will need:
* g++
* qt4-dev-tools
* flex
* bison
* libsdl-mixer??-dev
* libespeak-dev (if using the LINUX_ESPEAK option in BASIC256.pro)
- this option gives an integrated library approach to the say statement
* espeak (if using the LINUX_ESPEAK_EXECUTE option in BASIC256.pro)
- use this option and install if the library use of portaudio conflicts with other sound systems installed
* and the sqlite3 amalgamation installed from sqlite.org
Windows you will need:
* mingw c++ compiler for Win32 and the qt sdk
- the easiest way to get this installed and working is to use the
Qt SDK version 1.x.x from the downloas page at QT. Choose a custom install and select mingw to be installed
- You will have problems getting this to work if you do not have the EXACT mingw version required
- be sure you have the following (or similar) fildres listed in the PATH system variable
C:\QtSDK\mingw\bin and C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin
* gtk win32 bundle headers and libraries from http://www.gtk.org/download/win32.php
- extract the zip file to the mingw folder
* the gretl development headers need to be added to mingw they are in a file called mingw-extra.zip
and can be found at http://ricardo.ecn.wfu.edu/pub/gretl/winbuild/
* sqlite development libraries and headers need to be installed and downloaded fron http://www.sqlite.org/download.html
- use the *amalgation* zip file and copy the *.h files into MinGW/include
- download the windows dll zip file, extract files into MinGW/lib, and run the following
dlltool -D sqlite3.dll -d sqlite3.def -l libsqlite3dll.a
- you will also need to place the sqlite.dll file in the project/trunk/debug
and project/trunk/release folders.
* inpout32.dll
- download version 1.2 from http://www.highrez.co.uk/Downloads/InpOut32/default.htm
- copy the file inpout32.dll into MinGW/lib
- you will also need to place the inpout32.dll and inpout32.sys fileg in the project/trunk/debug
and project/trunk/release folders.
For MAC 10.6.4
- QT
- XCode (from apple)
- MACPorts (Porticus front end is handy)
- sqlite3
- flex
- libsdl_dev
- libsdl_dev-framework
- libsdl_mixer
- libsdl_mixer-framework
Build Windows MINGW, LINUX, and MACX (g++):
open a command window (cmd)
type "make clean" and hit enter
type "qmake" and hit enter - for MACX "qmake -spec macx-g++"
type "make" and hit enter
You'll see an executable called BASIC256 either in this directory or in a "debug" directory, depending on your version of QT.
linux: "make install" will install translations, help and binary You can then create a
launcher to "BASIC256" or "BASIC256 -l locale".
windows (observed under vista business sp2): make will not work because of Microsoft's command
line length issue. A possible work around would be to use 'msys'. It gives a unix like
shell to work from without the problem.
Release Build (Windows):
To build a nice WIN32 installer use the nullsoft scriptable install system file
2.39 or better) called BASIC256.nsi. You must build a release copy of BASCI256.
You must also copy the QtCore4.dll, QtGui4.dll, sqlite3.dll, and mingwm10.dll to the release
folder before testing the build or running the installer script. Under QT 4.5.3
be sure to use the dlls from C:\Qt\nnnn.nn\qt\bin and not the ones from C:\Qt\nnnn.nn\bin.
make clean
qmake -config release
make release
then run the NSIS script
CONTRIBUTORS 0000664 0001750 0001750 00000000626 11675357462 011104 0 ustar jim jim
Developers
-----------
Ian Larsen
Tony Dann
Ferry Hendrikx
Jim Reneau
Sergey Irupin
Translators
-----------
Immo-Gert Birn German
Ferry Hendrikx Dutch
Damir Shayhutdinov Russian
Sergey Irupin Russian
Javier González Spanish
DockWidget.cpp 0000664 0001750 0001750 00000002263 11675357462 011753 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**/
#include "DockWidget.h"
DockWidget::DockWidget( const QString & title, QWidget * parent, Qt::WindowFlags flags )
: QDockWidget( title, parent, flags )
, m_pWidget( NULL )
{
}
DockWidget::DockWidget( QWidget * parent, Qt::WindowFlags flags )
: QDockWidget( parent, flags )
, m_pWidget( NULL )
{
}
void DockWidget::setWidget( QWidget * vpWidget )
{
m_pWidget = vpWidget;
QDockWidget::setWidget( m_pWidget );
}
DockWidget.h 0000664 0001750 0001750 00000002117 11675357462 011416 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**/
#include
class DockWidget : public QDockWidget
{
Q_OBJECT
public:
DockWidget( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 );
DockWidget( QWidget * parent = 0, Qt::WindowFlags flags = 0 );
void setWidget( QWidget * vpWidget );
private:
QWidget * m_pWidget;
};
DocumentationWin.cpp 0000664 0001750 0001750 00000005777 11675357462 013233 0 ustar jim jim /** Copyright (C) 2010, J.M.Reneau, S.W.Irupin
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#include
using namespace std;
#include "DocumentationWin.h"
#include "MainWindow.h"
DocumentationWin::DocumentationWin (QWidget * parent)
:QDialog(parent)
{
QString localecode = ((MainWindow *) parent)->localecode;
QString windowsPath = QApplication::applicationDirPath() + "/help/";
QString linuxPath = "/usr/share/basic256/help/";
QString currentPath = "./";
QString indexfile = "index.html";
// position where it was last on screen
QSettings settings(SETTINGSORG, SETTINGSAPP);
resize(settings.value(SETTINGSDOCSIZE, QSize(700, 500)).toSize());
move(settings.value(SETTINGSDOCPOS, QPoint(150, 150)).toPoint());
docs = new QTextBrowser( this );
toolbar = new QToolBar( this );
QAction *backward = new QAction(QIcon(":images/backward.png"), tr("&Back"), this);
connect(backward, SIGNAL(triggered()), docs, SLOT(backward()));
connect(docs, SIGNAL(backwardAvailable(bool)), backward, SLOT(setEnabled(bool)));
toolbar->addAction(backward);
QAction *forward = new QAction(QIcon(":images/forward.png"), tr("&Forward"), this);
connect(forward, SIGNAL(triggered()), docs, SLOT(forward()));
connect(docs, SIGNAL(forwardAvailable(bool)), forward, SLOT(setEnabled(bool)));
toolbar->addAction(forward);
QAction *home = new QAction(QIcon(":images/home.png"), tr("&Home"), this);
connect(home, SIGNAL(triggered()), docs, SLOT(home()));
toolbar->addAction(home);
toolbar->addSeparator();
QAction *exit = new QAction(QIcon(":images/exit.png"), tr("&Exit"), this);
connect(exit, SIGNAL(triggered()), this, SLOT(close()));
toolbar->addAction(exit);
layout = new QVBoxLayout;
layout->addWidget(toolbar);
layout->addWidget(docs);
this->setLayout(layout);
this->setWindowTitle(QObject::tr("BASIC-256 Reference"));
this->show();
docs->setSearchPaths(QStringList()
<< windowsPath+localecode.left(2)
<< linuxPath+localecode.left(2)
<< currentPath+localecode.left(2)
<< windowsPath+"en"
<< linuxPath+"en"
<< currentPath+"en");
docs->setSource(QUrl(indexfile));
}
void DocumentationWin::resizeEvent(QResizeEvent *e) {
this->resize(size());
}
void DocumentationWin::closeEvent(QCloseEvent *e) {
QSettings settings(SETTINGSORG, SETTINGSAPP);
settings.setValue(SETTINGSDOCSIZE, size());
settings.setValue(SETTINGSDOCPOS, pos());
}
DocumentationWin.h 0000664 0001750 0001750 00000002307 11675357462 012662 0 ustar jim jim /** Copyright (C) 2010, J.M.Reneau.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#include
#include
#include
#include
#include
#ifndef DOCUMENTATIONWINH
#define DOCUMENTATIONWINH
class DocumentationWin : public QDialog
{
Q_OBJECT;
public:
DocumentationWin(QWidget * parent);
void resizeEvent(QResizeEvent *e);
void closeEvent(QCloseEvent *);
public slots:
private:
QVBoxLayout* layout;
QToolBar* toolbar;
QTextBrowser* docs;
};
#endif
EditSyntaxHighlighter.cpp 0000664 0001750 0001750 00000031740 11675357462 014204 0 ustar jim jim /**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**/
#include
#include "EditSyntaxHighlighter.h"
EditSyntaxHighlighter::EditSyntaxHighlighter(QTextDocument *parent)
: QSyntaxHighlighter(parent)
{
initKeywords();
initColors();
initFunctions();
initComments();
initQuotes();
}
void EditSyntaxHighlighter::highlightBlock(const QString &text)
{
HighlightRule rule;
VecHighlightRules::iterator sIt = m_standardRules.begin();
VecHighlightRules::iterator sItEnd = m_standardRules.end();
while (sIt != sItEnd)
{
rule = (*sIt);
QRegExp expression(rule.pattern);
int index = text.indexOf(expression);
while (index >= 0) {
int length = expression.matchedLength();
setFormat(index, length, rule.format);
index = text.indexOf(expression, index + length);
}
++sIt;
}
// Now do the functions, checking for calls to any matches.
VecHighlightRules::iterator fIt = m_functionRules.begin();
VecHighlightRules::iterator fItEnd = m_functionRules.end();
while (fIt != fItEnd)
{
rule = (*fIt);
QRegExp expression(rule.pattern);
int index = text.indexOf(expression);
while (index >= 0) {
int length = expression.matchedLength();
setFormat(index, length, rule.format);
index = text.indexOf(expression, index + length);
}
++fIt;
}
}
void EditSyntaxHighlighter::initKeywords()
{
HighlightRule rule;
m_keywordFmt.setForeground(Qt::darkBlue);
m_keywordFmt.setFontWeight(QFont::Bold);
QStringList keywordPatterns;
keywordPatterns
<< "\\b[Aa][Bb][Ss]\\b" // abs
<< "\\b[Aa][Cc][Oo][Ss]\\b" // acos
<< "\\b[Aa][Nn][Dd]\\b" // and
<< "\\b[Aa][Ss][Cc]\\b" // asc
<< "\\b[Aa][Ss][Ii][Nn]\\b" // asin
<< "\\b[Aa][Tt][Aa][Nn]\\b" // atan
<< "\\b[Cc][Ee][Ii][Ll]\\b" // ceil
<< "\\b[Cc][Hh][Aa][Nn][Gg][Ee][Dd][Ii][Rr]\\b" // changedir
<< "\\b[Cc][Hh][Rr]\\b" // chr
<< "\\b[Cc][Ii][Rr][Cc][Ll][Ee]\\b" // circle
<< "\\b[Cc][Ll][Ii][Cc][Kk][Bb]\\b" // clickb
<< "\\b[Cc][Ll][Ii][Cc][Kk][Cc][Ll][Ee][Aa][Rr]\\b" // clickclear
<< "\\b[Cc][Ll][Ii][Cc][Kk][Xx]\\b" // clickx
<< "\\b[Cc][Ll][Ii][Cc][Kk][Yy]\\b" // clicky
<< "\\b[Cc][Ll][Gg]\\b" // clg
<< "\\b[Cc][Ll][Oo][Ss][Ee]\\b" // close
<< "\\b[Cc][Ll][Ss]\\b" // cls
<< "\\b[Cc][Oo][Ll][Oo][Rr]\\b" // color
<< "\\b[Cc][Oo][Ll][Oo][Uu][Rr]\\b" // colour
<< "\\b[Cc][Oo][Ss]\\b" // cos
<< "\\b[Cc][Oo][Uu][Nn][Tt]\\b" // count
<< "\\b[Cc][Oo][Uu][Nn][Tt][Xx]\\b" // countx
<< "\\b[Cc][Uu][Rr][Rr][Ee][Nn][Tt][Dd][Ii][Rr]\\b" // currentdir
<< "\\b[Dd][Aa][Yy]\\b" // day
<< "\\b[Dd][Bb][Cc][Ll][Oo][Ss][Ee]\\b" // dbclose
<< "\\b[Dd][Bb][Cc][Ll][Oo][Ss][Ee][Ss][Ee][Tt]\\b" // dbcloseset
<< "\\b[Dd][Bb][Ee][Xx][Ee][Cc][Uu][Tt][Ee]\\b" // dbexecute
<< "\\b[Dd][Bb][Ff][Ll][Oo][Aa][Tt]\\b" // dbfloat
<< "\\b[Dd][Bb][Ii][Nn][Tt]\\b" // dbint
<< "\\b[Dd][Bb][Oo][Pp][Ee][Nn]\\b" // dbopen
<< "\\b[Dd][Bb][Oo][Pp][Ee][Nn][Ss][Ee][Tt]\\b" // dbopenset
<< "\\b[Dd][Bb][Rr][Oo][Ww]\\b" // dbrow
<< "\\b[Dd][Bb][Ss][Tt][Rr][Ii][Nn][Gg]\\b" // dbstring
<< "\\b[Dd][Ee][Cc][Ii][Mm][Aa][Ll]\\b" // decimal
<< "\\b[Dd][Ee][Gg][Rr][Ee][Ee][Ss]\\b" // degrees
<< "\\b[Dd][Ii][Mm]\\b" // dim
<< "\\b[Dd][Ii][Rr]\\b" // dir
<< "\\b[Dd][Oo]\\b" // do
<< "\\b[Ee][Dd][Ii][Tt][Vv][Ii][Ss][Ii][Bb][Ll][Ee]\\b" // editvisible
<< "\\b[Ee][Ll][Ss][Ee]\\b" // else
<< "\\b[Ee][Nn][Dd]\\b" // end
<< "\\b[Ee][Nn][Dd][Ii][Ff]\\b" // endif
<< "\\b[Ee][Nn][Dd][Ww][Hh][Ii][Ll][Ee]\\b" // endwhile
<< "\\b[Ee][Oo][Ff]\\b" // eof
<< "\\b[Ee][Xx][Ii][Ss][Tt][Ss]\\b" // exists
<< "\\b[Ee][Xx][Pp]\\b" // exp
<< "\\b[Ee][Xx][Pp][Ll][Oo][Dd][Ee]\\b" // explode
<< "\\b[Ee][Xx][Pp][Ll][Oo][Dd][Ee][Xx]\\b" // explodex
<< "\\b[Ff][Aa][Ss][Tt][Gg][Rr][Aa][Pp][Hh][Ii][Cc][Ss]\\b" // fastgraphics
<< "\\b[Ff][Ll][Oo][Oo][Rr]\\b" // floor
<< "\\b[Ff][Oo][Nn][Tt]\\b" // font
<< "\\b[Ff][Oo][Rr]\\b" // for
<< "\\b[Gg][Ee][Tt][Cc][Oo][Ll][Oo][Rr]\\b" // getcolor
<< "\\b[Gg][Ee][Tt][Ss][Ee][Tt][Tt][Ii][Nn][Gg]\\b" // getsetting
<< "\\b[Gg][Ee][Tt][Ss][Ll][Ii][Cc][Ee]\\b" // getslice
<< "\\b[Gg][Oo][Ss][Uu][Bb]\\b" // gosub
<< "\\b[Gg][Oo][Tt][Oo]\\b" // goto
<< "\\b[Gg][Rr][Aa][Pp][Hh][Hh][Ee][Ii][Gg][Hh][Tt]\\b" // graphheignt
<< "\\b[Gg][Rr][Aa][Pp][Hh][Ss][Ii][Zz][Ee]\\b" // graphsize
<< "\\b[Gg][Rr][Aa][Pp][Hh][Vv][Ii][Ss][Ii][Bb][Ll][Ee]\\b" // graphvisible
<< "\\b[Gg][Rr][Aa][Pp][Hh][Ww][Ii][Dd][Tt][Hh]\\b" // graphwidth
<< "\\b[Hh][Oo][Uu][Rr]\\b" // hour
<< "\\b[Ii][Ff]\\b" // if
<< "\\b[Ii][Mm][Gg][Ll][Oo][Aa][Dd]\\b" // imgload
<< "\\b[Ii][Mm][Gg][Ss][Aa][Vv][Ee]\\b" // imgsave
<< "\\b[Ii][Mm][Pp][Ll][Oo][Dd][Ee]\\b" // implode
<< "\\b[Ii][Nn][Pp][Uu][Tt]\\b" // input
<< "\\b[Ii][Nn][Ss][Tt][Rr]\\b" // instr
<< "\\b[Ii][Nn][Ss][Tt][Rr][Xx]\\b" // instrx
<< "\\b[Ii][Nn][Tt]\\b" // int
<< "\\b[Kk][Ee][Yy]\\b" // key
<< "\\b[Kk][Ii][Ll][Ll]\\b" // kill
<< "\\b[Ll][Aa][Ss][Tt][Ee][Rr][Rr][Oo][Rr]\\b" // lasterror
<< "\\b[Ll][Aa][Ss][Tt][Ee][Rr][Rr][Oo][Rr][Ee][Xx][Tt][Rr][Aa]\\b" // lasterrorextra
<< "\\b[Ll][Aa][Ss][Tt][Ee][Rr][Rr][Oo][Rr][Ll][Ii][Nn][Ee]\\b" // lasterrorline
<< "\\b[Ll][Aa][Ss][Tt][Ee][Rr][Rr][Oo][Rr][Mm][Ee][Ss][Ss][Aa][Gg][Ee]\\b"// lasterrormessage
<< "\\b[Ll][Ee][Ff][Tt]\\b" // left
<< "\\b[Ll][Ee][Nn][Gg][Tt][Hh]\\b" // length
<< "\\b[Ll][Ii][Nn][Ee]\\b" // line
<< "\\b[Ll][Oo][Gg]\\b" // log
<< "\\b[Ll][Oo][Gg][1][0]\\b" // log10
<< "\\b[Ll][Oo][Ww][Ee][Rr]\\b" // lower
<< "\\b[Mm][Dd][5]\\b" // md5
<< "\\b[Mm][Ii][Dd]\\b" // mid
<< "\\b[Mm][Ii][Nn][Uu][Tt][Ee]\\b" // minute
<< "\\b[Mm][Oo][Nn][Tt][Hh]\\b" // month
<< "\\b[Mm][Oo][Uu][Ss][Ee][Bb]\\b" // mouseb
<< "\\b[Mm][Oo][Uu][Ss][Ee][Xx]\\b" // mousex
<< "\\b[Mm][Oo][Uu][Ss][Ee][Yy]\\b" // mousey
<< "\\b[Mm][Ss][Ee][Cc]\\b" // msec
<< "\\b[Nn][Ee][Tt][Aa][Dd][Dd][Rr][Ee][Ss][Ss]\\b" // netaddress
<< "\\b[Nn][Ee][Tt][Cc][Ll][Oo][Ss][Ee]\\b" // netclose
<< "\\b[Nn][Ee][Tt][Cc][Oo][Nn][Nn][Ee][Cc][Tt]\\b" // netconnect
<< "\\b[Nn][Ee][Tt][Dd][Aa][Tt][Aa]\\b" // netdata
<< "\\b[Nn][Ee][Tt][Ll][Ii][Ss][Tt][Ee][Nn]\\b" // netlisten
<< "\\b[Nn][Ee][Tt][Rr][Ee][Aa][Dd]\\b" // netread
<< "\\b[Nn][Ee][Tt][Ww][Rr][Ii][Tt][Ee]\\b" // netwrite
<< "\\b[Nn][Ee][Xx][Tt]\\b" // next
<< "\\b[Nn][Oo][Tt]\\b" // not
<< "\\b[Oo][Ff][Ff][Ee][Rr][Rr][Oo][Rr]\\b" // offerror
<< "\\b[Oo][Nn][Ee][Rr][Rr][Oo][Rr]\\b" // onerror
<< "\\b[Oo][Pp][Ee][Nn]\\b" // open
<< "\\b[Oo][Rr]\\b" // or
<< "\\b[Oo][Ss][Tt][Yy][Pp][Ee]\\b" // ostype
<< "\\b[Oo][Uu][Tt][Pp][Uu][Tt][Vv][Ii][Ss][Ii][Bb][Ll][Ee]\\b" // outputvisible
<< "\\b[Pp][Aa][Uu][Ss][Ee]\\b" // pause
<< "\\b[Pp][Ii]\\b" // pi
<< "\\b[Pp][Ii][Xx][Ee][Ll]\\b" // pixel
<< "\\b[Pp][Ll][Oo][Tt]\\b" // plot
<< "\\b[Pp][Oo][Ll][Yy]\\b" // poly
<< "\\b[Pp][Oo][Rr][Tt][Ii][Nn]\\b" // portin
<< "\\b[Pp][Oo][Rr][Tt][Oo][Uu][Tt]\\b" // portout
<< "\\b[Pp][Rr][Ii][Nn][Tt]\\b" // print
<< "\\b[Pp][Uu][Tt][Ss][Ll][Ii][Cc][Ee]\\b" // putslice
<< "\\b[Rr][Aa][Dd][Ii][Aa][Nn][Ss]\\b" // radians
<< "\\b[Rr][Aa][Nn][Dd]\\b" // rand
<< "\\b[Rr][Ee][Aa][Dd]\\b" // read
<< "\\b[Rr][Ee][Aa][Dd][Ll][Ii][Nn][Ee]\\b" // readline
<< "\\b[Rr][Ee][Cc][Tt]\\b" // rect
<< "\\b[Rr][Ee][Dd][Ii][Mm]\b" // redim
<< "\\b[Rr][Ee][Ff][Rr][Ee][Ss][Hh]\\b" // refresh
<< "\\b[Rr][Ee][Pp][Ll][Aa][Cc][Ee]\\b" // replace
<< "\\b[Rr][Ee][Pp][Ll][Aa][Cc][Ee][Xx]\\b" // replacex
<< "\\b[Rr][Ee][Ss][Ee][Tt]\\b" // reset
<< "\\b[Rr][Ee][Tt][Uu][Rr][Nn]\\b" // return
<< "\\b[Rr][Gg][Bb]\\b" // rgb
<< "\\b[Rr][Ii][Gg][Hh][Tt]\\b" // right
<< "\\b[Ss][Aa][Yy]\\b" // say
<< "\\b[Ss][Ee][Cc][Oo][Nn][Dd]\\b" // second
<< "\\b[Ss][Ee][Ee][Kk]\\b" // seek
<< "\\b[Ss][Ee][Tt][Ss][Ee][Tt][Tt][Ii][Nn][Gg]\\b" // setsetting
<< "\\b[Ss][Ii][Nn]\\b" // sin
<< "\\b[Ss][Ii][Zz][Ee]\\b" // size
<< "\\b[Ss][Oo][Uu][Nn][Dd]\\b" // sound
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Cc][Oo][Ll][Ll][Ii][Dd][Ee]\\b" // spritedcollide
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Dd][Ii][Mm]\\b" // spritedim
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Hh]\\b" // spriteh
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Hh][Ii][Dd][Ee]\\b" // spritehide
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Ll][Oo][Aa][Dd]\\b" // spriteload
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Mm][Oo][Vv][Ee]\\b" // spritemove
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Pp][Ll][Aa][Cc][Ee]\\b" // spriteplace
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Ss][Hh][Oo][Ww]\\b" // spriteshow
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Ss][Ll][Ii][Cc][Ee]\\b" // spriteslice
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Vv]\\b" // spritev
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Ww]\\b" // spritew
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Xx]\\b" // spritex
<< "\\b[Ss][Pp][Rr][Ii][Tt][Ee][Yy]\\b" // spritey
<< "\\b[Ss][Qq][Rr]\\b" // sqr
<< "\\b[Ss][Qq][Rr][Tt]\\b" // sqrt
<< "\\b[Ss][Tt][Aa][Mm][Pp]\\b" // stamp
<< "\\b[Ss][Tt][Ee][Pp]\\b" // step
<< "\\b[Ss][Yy][Ss][Tt][Ee][Mm]\\b" // system
<< "\\b[Tt][Aa][Nn]\\b" // tan
<< "\\b[Tt][Ee][Xx][Tt]\\b" // text
<< "\\b[Tt][Hh][Ee][Nn]\\b" // then
<< "\\b[Tt][Oo]\\b" // to
<< "\\b[Ss][Tt][Rr][Ii][Nn][Gg]\\b" // tostring
<< "\\b[Uu][Nn][Tt][Ii][Ll]\\b" // until
<< "\\b[Uu][Pp][Pp][Ee][Rr]\\b" // upper
<< "\\b[Vv][Oo][Ll][Uu][Mm][Ee]\\b" // volume
<< "\\b[Ww][Aa][Vv][Pp][Ll][Aa][Yy]\\b" // wavplay
<< "\\b[Ww][Aa][Vv][Ss][Tt][Oo][Pp]\\b" // wavstop
<< "\\b[Ww][Aa][Vv][Ww][Aa][Ii][Tt]\\b" // wavwait
<< "\\b[Ww][Hh][Ii][Ll][Ee]\\b" // while
<< "\\b[Ww][Rr][Ii][Tt][Ee]\\b" // write
<< "\\b[Ww][Rr][Ii][Tt][Ee][Ll][Ii][Nn][Ee]\\b" // writeline
<< "\\b[Xx][Oo][Rr]\\b" // xor
<< "\\b[Yy][Ee][Aa][Rr]\\b" // year
;
for (QStringList::iterator it = keywordPatterns.begin(); it != keywordPatterns.end(); ++it)
{
rule.pattern = QRegExp(*it);
rule.format = m_keywordFmt;
m_standardRules.append(rule);
}
}
void EditSyntaxHighlighter::initColors()
{
HighlightRule rule;
m_colorFmt.setForeground(Qt::darkCyan);
QStringList colorPatterns;
colorPatterns
<< "\\b[Tt][Rr][Uu][Ee]\\b" // true
<< "\\b[Ff][Aa][Ll][Ss][Ee]\\b" // false
<< "\\b[Cc][Ll][Ee][Aa][Rr]\\b" // clear
<< "\\b[Bb][Ll][Aa][Cc][Kk]\\b" // black
<< "\\b[Ww][Hh][Ii][Tt][Ee]\\b" // white
<< "\\b([Dd][Aa][Rr][Kk]){0,1}[Rr][Ee][Dd]\\b" // red and darkred
<< "\\b([Dd][Aa][Rr][Kk]){0,1}[Gg][Rr][Ee][Ee][Nn]\\b" // green and darkgreen
<< "\\b([Dd][Aa][Rr][Kk]){0,1}[Bb][Ll][Uu][Ee]\\b" // blue and darkblue
<< "\\b([Dd][Aa][Rr][Kk]){0,1}[Cc][Yy][Aa][Nn]\\b" // cyan and darkcyan
<< "\\b([Dd][Aa][Rr][Kk]){0,1}[Pp][Uu][Rr][Pp][Ll][Ee]\\b" // purple and darkpurple
<< "\\b([Dd][Aa][Rr][Kk]){0,1}[Yy][Ee][Ll][Ll][Oo][Ww]\\b" // yellow and darkyellow
<< "\\b([Dd][Aa][Rr][Kk]){0,1}[Oo][Rr][Aa][Nn][Gg][Ee]\\b" // orange and darkorange
<< "\\b([Dd][Aa][Rr][Kk]){0,1}[Gg][Rr][AaEe][Yy]\\b" // gray and darkgrey
;
for (QStringList::iterator it = colorPatterns.begin(); it != colorPatterns.end(); ++it )
{
rule.pattern = QRegExp(*it);
rule.format = m_colorFmt;
m_standardRules.append(rule);
}
}
void EditSyntaxHighlighter::initQuotes()
{
HighlightRule rule;
m_quoteFmt.setForeground(Qt::darkRed);
rule.pattern = QRegExp("\"[^\"]*\"");
rule.format = m_quoteFmt;
m_standardRules.append(rule);
}
void EditSyntaxHighlighter::initFunctions()
{
HighlightRule rule;
m_functionFmt.setForeground(Qt::blue);
rule.pattern = QRegExp("\\b[A-Za-z0-9]+(?=\\:$)");
rule.format = m_functionFmt;
m_functionRules.append(rule);
}
void EditSyntaxHighlighter::initComments()
{
HighlightRule rule;
m_commentFmt.setForeground(Qt::darkGreen);
m_commentFmt.setFontItalic(true);
rule.pattern = QRegExp("(([Rr][Ee][Mm][ ].+)|([Rr][Ee][Mm])|#.*)$");
rule.format = m_commentFmt;
m_standardRules.append(rule);
}
EditSyntaxHighlighter.h 0000664 0001750 0001750 00000003245 11675357462 013650 0 ustar jim jim /**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**/
#ifndef __EDITSYNTAXHIGHLIGHTER_H
#define __EDITSYNTAXHIGHLIGHTER_H
#include
//#include
#include
class QTextDocument;
class EditSyntaxHighlighter : public QSyntaxHighlighter
{
Q_OBJECT
public:
EditSyntaxHighlighter(QTextDocument *parent = 0);
protected:
virtual void highlightBlock(const QString &text);
private:
struct HighlightRule
{
QRegExp pattern;
QTextCharFormat format;
};
typedef QVector< HighlightRule > VecHighlightRules;
VecHighlightRules m_standardRules;
VecHighlightRules m_functionRules;
void initKeywords();
void initColors();
void initQuotes();
void initFunctions();
void initComments();
QTextCharFormat m_keywordFmt;
QTextCharFormat m_colorFmt;
QTextCharFormat m_quoteFmt;
QTextCharFormat m_functionFmt;
QTextCharFormat m_commentFmt;
};
#endif // __EDITSYNTAXHIGHLIGHTER_H
ErrorCodes.h 0000664 0001750 0001750 00000012262 11675357462 011443 0 ustar jim jim /** Copyright (C) 2006, Ian Paul Larsen.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License along
** with this program; if not, write to the Free Software Foundation, Inc.,
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#ifndef ERROR_NONE
#define ERROR_NONE 0
#define ERROR_NOSUCHLABEL 1
#define ERROR_NOSUCHLABEL_MESSAGE "No such label"
#define ERROR_FOR1 2
#define ERROR_FOR1_MESSAGE "Illegal FOR -- start number > end number"
#define ERROR_FOR2 3
#define ERROR_FOR2_MESSAGE "Illegal FOR -- start number < end number"
#define ERROR_NEXTNOFOR 4
#define ERROR_NEXTNOFOR_MESSAGE "Next without FOR"
#define ERROR_FILENUMBER 5
#define ERROR_FILENUMBER_MESSAGE "Invalid File Number"
#define ERROR_FILEOPEN 6
#define ERROR_FILEOPEN_MESSAGE "Unable to open file"
#define ERROR_FILENOTOPEN 7
#define ERROR_FILENOTOPEN_MESSAGE "File not open."
#define ERROR_FILEWRITE 8
#define ERROR_FILEWRITE_MESSAGE "Unable to write to file"
#define ERROR_FILERESET 9
#define ERROR_FILERESET_MESSAGE "Unable to reset file"
#define ERROR_ARRAYSIZELARGE 10
#define ERROR_ARRAYSIZELARGE_MESSAGE "Array dimension too large"
#define ERROR_ARRAYSIZESMALL 11
#define ERROR_ARRAYSIZESMALL_MESSAGE "Array dimension too small"
#define ERROR_NOSUCHVARIABLE 12
#define ERROR_NOSUCHVARIABLE_MESSAGE "Unknown variable"
#define ERROR_NOTARRAY 13
#define ERROR_NOTARRAY_MESSAGE "Not an array variable"
#define ERROR_NOTSTRINGARRAY 14
#define ERROR_NOTSTRINGARRAY_MESSAGE "Not a string array variable"
#define ERROR_ARRAYINDEX 15
#define ERROR_ARRAYINDEX_MESSAGE "Array index out of bounds"
#define ERROR_STRNEGLEN 16
#define ERROR_STRNEGLEN_MESSAGE "Substring length less that zero"
#define ERROR_STRSTART 17
#define ERROR_STRSTART_MESSAGE "Starting position less than zero"
#define ERROR_STREND 18
#define ERROR_STREND_MESSAGE "String not long enough for given starting character"
#define ERROR_NONNUMERIC 19
#define ERROR_NONNUMERIC_MESSAGE "Non-numeric value in numeric expression"
#define ERROR_RGB 20
#define ERROR_RGB_MESSAGE "RGB Color values must be in the range of 0 to 255."
#define ERROR_PUTBITFORMAT 21
#define ERROR_PUTBITFORMAT_MESSAGE "String input to putbit incorrect."
#define ERROR_POLYARRAY 22
#define ERROR_POLYARRAY_MESSAGE "Argument not an array for poly()/stamp()"
#define ERROR_POLYPOINTS 23
#define ERROR_POLYPOINTS_MESSAGE "Not enough points in array for poly()/stamp()"
#define ERROR_IMAGEFILE 24
#define ERROR_IMAGEFILE_MESSAGE "Unable to load image file."
#define ERROR_SPRITENUMBER 25
#define ERROR_SPRITENUMBER_MESSAGE "Sprite number out of range."
#define ERROR_SPRITENA 26
#define ERROR_SPRITENA_MESSAGE "Sprite has not been assigned."
#define ERROR_SPRITESLICE 27
#define ERROR_SPRITESLICE_MESSAGE "Unable to slice image."
#define ERROR_FOLDER 28
#define ERROR_FOLDER_MESSAGE "Invalid directory name."
#define ERROR_DECIMALMASK 29
#define ERROR_DECIMALMASK_MESSAGE "Decimal mask must be in the range of 0 to 15."
#define ERROR_DBOPEN 30
#define ERROR_DBOPEN_MESSAGE "Unable to open SQLITE database."
#define ERROR_DBQUERY 31
#define ERROR_DBQUERY_MESSAGE "Database query error (message follows)."
#define ERROR_DBNOTOPEN 32
#define ERROR_DBNOTOPEN_MESSAGE "Database must be opened first."
#define ERROR_DBCOLNO 33
#define ERROR_DBCOLNO_MESSAGE "Column number out of range."
#define ERROR_DBNOTSET 34
#define ERROR_DBNOTSET_MESSAGE "Record set must be opened first."
#define ERROR_EXTOPBAD 35
#define ERROR_EXTOPBAD_MESSAGE "Invalid Extended Op-code."
#define ERROR_NETSOCK 36
#define ERROR_NETSOCK_MESSAGE "Error opening network socket."
#define ERROR_NETHOST 37
#define ERROR_NETHOST_MESSAGE "Error finding network host."
#define ERROR_NETCONN 38
#define ERROR_NETCONN_MESSAGE "Unable to connect to network host."
#define ERROR_NETREAD 39
#define ERROR_NETREAD_MESSAGE "Unable to read from network connection."
#define ERROR_NETNONE 40
#define ERROR_NETNONE_MESSAGE "Network connection has not been opened."
#define ERROR_NETWRITE 41
#define ERROR_NETWRITE_MESSAGE "Unable to write to network connection."
#define ERROR_NETSOCKOPT 42
#define ERROR_NETSOCKOPT_MESSAGE "Unable to set network socket options."
#define ERROR_NETBIND 43
#define ERROR_NETBIND_MESSAGE "Unable to bind network socket."
#define ERROR_NETACCEPT 44
#define ERROR_NETACCEPT_MESSAGE "Unable to accept network connection."
#define ERROR_NETSOCKNUMBER 45
#define ERROR_NETSOCKNUMBER_MESSAGE "Invalid Socket Number"
#define ERROR_PERMISSION 46
#define ERROR_PERMISSION_MESSAGE "You do not have permission to use this statement/function."
#define ERROR_IMAGESAVETYPE 47
#define ERROR_IMAGESAVETYPE_MESSAGE "Invalid image save type."
//
#define ERROR_NOTIMPLEMENTED 9999
#define ERROR_NOTIMPLEMENTED_MESSAGE "Feature not implemented in this environment."
#endif
Examples/ 0000775 0001750 0001750 00000000000 11675357447 011001 5 ustar jim jim Examples/sliceanimation.kbs 0000664 0001750 0001750 00000002003 11675357447 014474 0 ustar jim jim # sliceanimation.kbs
# 2010-05-08 j.m.reneau
# demonstration program of getslice function
# and putslice statements.
fastgraphics
# capture slice of red foreground and white background
clg
color red
gosub randomdraw
refresh
slice$ = getslice(100,100,100,100)
# draw a screen of yellow and black to
# draw slice onto
color yellow
rect 0,0,300,300
color black
gosub randomdraw
refresh
# initial place and direction
x = 0
dx = rand * 3 + 1
y = 0
dy = rand * 3 + 1
while true
# get new loction to put slise at
x = x + dx
if x < 0 or x > 200 then dx = dx * -1
y = y + dy
if y < 0 or y > 200 then dy = dy * -1
# get whet is there before putting slice
original$ = getslice(x,y,100,100)
# draw the slize with white as a transparent color
putslice x,y,slice$,black
refresh
# change it back to what it was before the slice
putslice x,y,original$
end while
end
randomdraw:
# crap on the screen for example
for t = 1 to 100
line rand * 300, rand * 300, rand * 300, rand * 300
next t
return
Examples/BASICtest1.kbs 0000664 0001750 0001750 00000000722 11675357447 013305 0 ustar jim jim REM arithmetic operator test
if 4 < 5 then print "PASS <"
if 5 < 4 then print "FAIL <"
if 5 > 4 then print "PASS >"
if 4 > 5 then print "FAIL >"
if 4 <= 5 then print "PASS <="
if 5 <= 5 then print "PASS <="
if 5 <= 4 then print "FAIL <="
if 4 >= 4 then print "PASS >="
if 5 >= 5 then print "PASS >="
if 4 >= 5 then print "FAIL >="
if 4 = 4 then print "PASS ="
if 4 = 5 then print "FAIL ="
if 4 <> 5 then print "PASS <>"
if 4 <> 4 then print "FAIL <>"
Examples/cards_deal5.kbs 0000664 0001750 0001750 00000005361 11675357447 013655 0 ustar jim jim # 2009-12-25 j.m.reneau
# create a deck of cards, shuffle them, and display
# 5 of them graphically on the screen
# requires 0.9.4g
#
# shapes of the card suits
dim diamond(8)
diamond = {0, 2.5, 2, 0, 4, 2.5, 2, 5}
dim heart(12)
heart = {0, 1, 1, 0, 2, 1, 3, 0, 4, 1, 2, 5}
dim spade(18)
spade = {0, 3, 2, 0, 4, 3, 4, 4, 2, 3, 3, 5, 1, 5, 2, 3, 0, 4}
dim club(30)
club = {0, 1, 1, 0, 2, 1, 3, 0, 4, 1, 3, 2, 4, 3, 3, 4, 2, 3, 3, 5, 1, 5, 2, 3, 1, 4, 0, 3, 1, 2}
#
# suits and faces
dim suits$(4)
suits$ = {"D", "H", "S", "C"}
dim cards$(13)
cards$ = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J" ,"Q", "K"}
#
# array to hold the shuffled deck
dim deck$(52)
gosub makedeck
gosub shuffledeck
clg
# draw poker table
color 139,69,19
rect 0,0,300,300
color darkgreen
rect 10,10,280,280
print "click on cards to turn over"
# show 5 cards face down
for t = 1 to 5
x = 25 + t*40
y = 100
gosub drawcardback
next t
clickloop:
pause .1
# if we have not clicked - go back and wait
if clickb = -1 then goto clickloop
card1 = -1
# see if the click was on a card
for t = 1 to 5
if clickx >= 25 + t*40 and clickx <= 55 + t*40 and clicky >= 100 and clicky <= 150 then card1 = t
next t
# clear the click
clickclear
if card1 = -1 then goto clickloop
# we clicked on a card - show it
card$ = deck$[card1]
x = 25 + card1*40
y = 100
gosub drawcard
goto clickloop
end
makedeck: #
# makedeck - loop through the suits$ and cards$ arrays
# to build 52 card deck$
for suit = 0 to 3
for card = 0 to 12
deck$[suit*13+card] = suits$[suit] + cards$[card]
next card
next suit
return
shuffledeck: #
# shuffledeck - for many times pick two random
# cards from the deck and switch them
for t = 1 to 200
card1 = int(rand*52)
card2 = int(rand*52)
card$ = deck$[card2]
deck$[card2] = deck$[card1]
deck$[card1] = card$
next t
return
drawcardback: #
# draw a moire pattern for the back of a card
gosub drawcardborder
color blue
for card1 = 3 to 30 step 4
line x+2,y+2,x+card1,y+48
next card1
for card1 = 3 to 50 step 4
line x+2,y+2,x+28,y+card1
next card1
return
drawcardborder: #
# draw blank card with border
color blue
rect x,y,30,50
color white
rect x+2,y+2,26,46
return
drawcard: #
# drawcard - draw a 30x50 card at the location x,y
# on the screen. also set card$ to be the card
# you want to be displayed
#
# set card color
gosub drawcardborder
color black
if mid(card$,1,1) = "H" or mid(card$,1,1) = "D" then color red
# stamp suit on card
if mid(card$,1,1) = "H" then stamp x+7, y+26, 4, heart
if mid(card$,1,1) = "D" then stamp x+7, y+26, 4, diamond
if mid(card$,1,1) = "S" then stamp x+7, y+26, 4, spade
if mid(card$,1,1) = "C" then stamp x+7, y+26, 4, club
# now show card value
font "tahoma",13,100
text x + 4, y + 1, mid(card$,2,2)
return
Examples/networking/ 0000775 0001750 0001750 00000000000 11675357445 013166 5 ustar jim jim Examples/networking/netgetmany.kbs 0000664 0001750 0001750 00000001037 11675357445 016043 0 ustar jim jim # open 5 network connections at once
dim a$(5)
dim t$(5)
a$ = { "www.google.com", "www.yahoo.com", "www.cnn.com", "www.espn.com", "www.basic256.org"}
for t = 0 to 4
NETCONNECT t, a$[t], 80
print t + " connected to " + a$[t]
next t
for t = 0 to 4
NETWRITE t, "GET HTTP/1.1" + chr(13) + chr(10) + chr(13) + chr(10)
print t + " request written"
next t
for t = 0 to 4
t$[t] = NETREAD(t)
print t + " read"
next t
for t = 0 to 4
print t + " " + left(t$[t],40)
next t
for t = 0 to 4
netclose t
print t + " closed"
next t
Examples/networking/netclient.kbs 0000664 0001750 0001750 00000000346 11675357445 015657 0 ustar jim jim # have the user enter a message and send it to the server
input "enter message?", m$
netconnect "127.0.0.1", 9997
for t = 1 to 10
pause rand
netwrite t + " " + m$
print netread
next t
netwrite "end"
print netread
netclose Examples/networking/netserver.kbs 0000664 0001750 0001750 00000000404 11675357445 015702 0 ustar jim jim # get a message and send back success
print "wait for connection"
netlisten 9997
print "got connection"
do
while not netdata
pause .1
print ".";
end while
n$ = netread
print n$
netwrite "I got '" + n$ + "'."
until n$ = "end"
netclose Examples/networking/netgoogle.kbs 0000664 0001750 0001750 00000000230 11675357445 015645 0 ustar jim jim NETCONNECT "www.google.com", 80
print "connected"
NETWRITE "GET HTTP/1.1" + chr(13) + chr(10) + chr(13) + chr(10)
print "written"
print NETREAD
NETCLOSE Examples/networking/netgethomepage.kbs 0000664 0001750 0001750 00000001152 11675357445 016662 0 ustar jim jim # netgethomepage.kbs - connect to a web site and download
# the home page into a variable
site$ = "www.yahoo.com"
port = 80
NETCONNECT site$, port
print "connected to " + site$ + ":" + port
get$ = "GET http://" + site$ + "/ HTTP/1.0" + chr(13) + chr(10)
get$ = get$ + chr(13) + chr(10)
NETWRITE get$
print "request written"
s$ = ""
do
chunk$ = netread
print "chunk '" + left(chunk$,10) + "..." + right(chunk$,10) + "'" + length(chunk$)
s$ = s$ + chunk$
# wait for more data / may need to adjust for a slower connection
pause .2
until not netdata
NETCLOSE
print "response"
print s$
print length(s$)
Examples/tictactoe_comp.kbs 0000664 0001750 0001750 00000013131 11675357447 014476 0 ustar jim jim # tictactoe_comp
# with a computer player - 2009-12-25 - j.m.reneau
# requires BACIC256 0.9.4g or better
# -1=empty 0=x, 1=0
fastgraphics
dim board(9)
board = {-1,-1,-1,-1,-1,-1,-1,-1,-1}
gosub drawboard
print "tictactoe"
dim playertype$(2)
for t = 0 to 1
do
print "who is player " + (t+1) + " (c-computer, h-human)";
input playertype$[t]
until playertype$[t] = "c" or playertype$[t] = "h"
next t
player = 1
otherplayer = 0
do
# swap player and otherplayer
t = player
player = otherplayer
otherplayer = t
# play the player
if playertype$[player] = "h" then gosub humanplayer
if playertype$[player] = "c" then gosub computerplayer
#
gosub drawboard
# see if there is a winner and if not loop for next player
gosub iswinner
until winner <> -1
# we must have a winner
print "The winner was ";
if winner = 0 then print "X"
if winner = 1 then print "O"
if winner = 2 then print "cat"
end
humanplayer:
print "player ";
if player = 0 then
print "X";
else
print "O";
end if
print " please click on cell."
clickclear
while clickb = 0
pause .1
endwhile
# what cell did they click on
i = int(clickx/100) + int(clicky/100)*3
# if it is not empty then wait again
if board[i] <> -1 then goto humanplayer
# set cell and display
board[i] = player
return
computerplayer:
# go through each square and if it is a win do it
# find the best offensive move I can make and save in mybest - we may do it later
mybest = -1
mybesttwofer = 0
twoferplayer = player
for i = 0 to 8
if board[i] = -1 then
board[i] = player
gosub iswinner
if winner = player then return
gosub counttwofer
if twofer > mybesttwofer then
mybesttwofer = twofer
mybest = i
endif
board[i] = -1
endif
next i
#
# go through each square and if it is a win for the other guy - block it
# find the best defensive move I can make and save in hisbest - we may do it later
hisbest = -1
hisbesttwofer = 0
twoferplayer = otherplayer
for i = 0 to 8
if board[i] = -1 then
board[i] = otherplayer
gosub iswinner
if winner = otherplayer then
board[i] = player
return
endif
gosub counttwofer
if twofer > hisbesttwofer then
hisbesttwofer = twofer
hisbest = i
endif
board[i] = -1
endif
next i
#
# if we can stop a 2 way 2fer stop it
if hisbesttwofer >= 2 then
board[hisbest] = player
return
endif
#
# if we can get a 2 way 2fer do it
if mybesttwofer >= 2 then
board[mybest] = player
return
endif
#
# if we can stop a 1 way 2fer stop it
if hisbesttwofer = 1 then
board[hisbest] = player
return
endif
#
# if we can get a 1 way 2fer do it
if mybesttwofer = 1 then
board[mybest] = player
return
endif
#
# last resort make a random move
# - loop until we randomly select an empty cell
do
i = int(rand * 9)
until board[i] = -1
board[i] = player
return
iswinner: #
# is there a winner = return winner - -1 if ther game continues
# winner = 0 for X, winner=1 for Y, winner=2 for cat
for winner = 0 to 1
# check columns
for t = 0 to 2
if board[0+t] = winner and board[3+t] = winner and board[6+t] = winner then return
next t
# check rows
for t = 0 to 2
if board[3*t] = winner and board[3*t+1] = winner and board[3*t+2] = winner then return
next t
# check diagonals
if board[0] = winner and board[4] = winner and board[8] = winner then return
if board[2] = winner and board[4] = winner and board[6] = winner then return
next winner
# check for empty square
winner = -1
for t = 0 to 8
if board[t]=-1 then return
next t
# must be a cat
winner = 2
return
counttwofer: #
# count the number of 2 in a row with a blank for twoferplayer
# return as twofers
# check columns
twofer = 0
for t = 0 to 2
if board[0+t] = twoferplayer and board[3+t] = twoferplayer and board[6+t] = -1 then twofer = twofer + 1
if board[0+t] = twoferplayer and board[3+t] = -1 and board[6+t] = twoferplayer then twofer = twofer + 1
if board[0+t] = -1 and board[3+t] = twoferplayer and board[6+t] = twoferplayer then twofer = twofer + 1
next t
# check rows
for t = 0 to 2
if board[3*t] = twoferplayer and board[3*t+1] = twoferplayer and board[3*t+2] = -1 then twofer = twofer + 1
if board[3*t] = twoferplayer and board[3*t+1] = -1 and board[3*t+2] = twoferplayer then twofer = twofer + 1
if board[3*t] = -1 and board[3*t+1] = twoferplayer and board[3*t+2] = twoferplayer then twofer = twofer + 1
next t
# check diagonals
if board[0] = twoferplayer and board[4] = twoferplayer and board[8] = -1 then twofer = twofer + 1
if board[0] = twoferplayer and board[4] = -1 and board[8] = twoferplayer then twofer = twofer + 1
if board[0] = -1 and board[4] = twoferplayer and board[8] = twoferplayer then twofer = twofer + 1
if board[2] = twoferplayer and board[4] = twoferplayer and board[6] = -1 then twofer = twofer + 1
if board[2] = twoferplayer and board[4] = -1 and board[6] = twoferplayer then twofer = twofer + 1
if board[2] = -1 and board[4] = twoferplayer and board[6] = twoferplayer then twofer = twofer + 1
return
drawboard: #
clg
color black
rect 0,95,300,10
rect 0,195,300,10
rect 95,0,10,300
rect 195,0,10,300
#
font "Tahoma",50,100
# draw X and O
for t = 0 to 8
if board[t]=0 then color red : text ((t % 3)*100)+25, (int(t/3)*100)+10, "X"
if board[t]=1 then color blue : text ((t % 3)*100)+25, (int(t/3)*100)+10, "O"
next t
refresh
return
Examples/story.kbs 0000664 0001750 0001750 00000002632 11675357447 012665 0 ustar jim jim
rem Wacky Story
input "Name? ", name$
input "Noun? ", noun1$
input "Adverb? ", adverb1$
input "Verb? ", verb1$
input "Noun? ", noun2$
input "Noun? ", noun3$
input "Adjective? ", adj1$
input "Noun? ", noun4$
input "Verb? ", verb4$
input "Adverb? ", adverb2$
input "Noun? ", noun5$
input "Noun? ", noun6$
input "Verb? ", verb3$
input "Noun? ", noun7$
rem *story*
print "*********************"
print "One dark and stormy night, " + name$;
print " and her " + noun1$ + " were fast asleep in their beds. ";
print " Suddenly, they heard a crack of " + noun2$;
print ", followed quickly by a streak of " + noun3$ + " in the sky."
print ""
print name$ + " sat up and screamed. She could feel the ";
print noun4$ + " running down her neck as she " + adverb1$ + " ";
print verb1$ + " around the room. When her gaze landed on her ";
print noun1$ + "'s bed, she realized that he wasn't there. "
print ""
print "She looked at the " + noun5$ + ". It was midnight. She took deep breaths,";
print " waiting for her " + noun1$ + " to return.";
print " An hour later, he still wasn't there. "
print ""
print name$ + " climbed out of ";
print noun6$ + "and stood up, her legs ";
print adj1$ + ". She walked " + adverb2$;
print " out of the room and into the kitchen. And there she found him, eating a ";
print noun7$ + ". Outside, the " + noun2$ + " crashed again and Sally ";
print verb3$ + " and " + verb4$ + " back to bed."
print " "
Examples/plot2.kbs 0000664 0001750 0001750 00000000060 11675357447 012536 0 ustar jim jim
color yellow
for a = 1 to 100
plot a, a
next a
Examples/sqrt.kbs 0000664 0001750 0001750 00000001112 11675357447 012466 0 ustar jim jim # calculate the square root geometrically (according to Heron)
# Carsten Berndt, 2007
clg
cls
fastgraphics
zuWurzeln=56224
zuZeichnen=zuWurzeln
zweiteZahl=1
delta=0.000001
print "sqrt("; : print zuWurzeln; : print ") =" ;
MainLoop:
clg
rect 0, 0, zuZeichnen, zweiteZahl
zuZeichnen = (zuZeichnen+zweiteZahl)/2
zweiteZahl = zuWurzeln/zuZeichnen
if zuZeichnen-zweiteZahl