New to GLbasic but used to older lsanguages

Previous topic - Next topic

shaf

Hello,

I was expecting GLbasic to be similar to Basic but with Structured commands and similar syntax.
Currently I'm converting some very old Basic Programs (Circa 1983).

Is there a table comparing ANSI Basic Commands with GLBasic equivalents?

Thanks

Shaf

p.s. Gernot it's your postings on RetroRemakes that got me interested in GLBasic.

x-tra

What is RR?
Raidr... ???

What posting?

Kitty Hello

The main difference between GLBasic and old-school basic is the working with arrays:
old school:
Code (glbasic) Select
DIM arr(0 TO 9)
arr(0) = 5
GLBasic
Code (glbasic) Select
DIM arr[10]
arr[0] = 5

shaf

I did figure out how to use the array function the one i don't understand is how to read data

Basic Example
 For I = 1 to 10
  read rm$(i)
  next i
data 2,0,0,0,0,0,0

GLbasic example
 for I = 1 to 10
  ????? rm$(i)
  next
????? 2,0,0,0,0,0,0

bigsofty

Boom... one command...

Code (glbasic) Select
DIMDATA rm$[], 2,0,0,0,0,0,0GLBasic is not the same, it is superior in many ways.

Post any more conversions problem here, Ill try to help...
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Right. The DIMDATA command allows to generate READ commands at _compile_ time. Very fast.

shaf

That was very helpful, I thingK i can nowe complete the program that I am  working on. It's a very simple Text adventure based on something i found on an old Compute! book.

I'll post it into showcase if anyone is interested.

bigsofty

Yeah, please do, I go a soft spot for the old interactive fiction...
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Brice Manuel

QuoteGLBasic is not the same, it is superior in many ways.
Sorry, but how is this supposed to replace 100s or even 1000s of lines of traditional DATA?

I still miss traditional read/data/restore and that is the ONLY reason that I only use GLBasic for prototyping and not for final projects.

bigsofty

Quote from: Brice Manuel
QuoteGLBasic is not the same, it is superior in many ways.
Sorry, but how is this supposed to replace 100s or even 1000s of lines of traditional DATA?

I still miss traditional read/data/restore and that is the ONLY reason that I only use GLBasic for prototyping and not for final projects.
Really?

No program nowadays should have 100s or 1000s of data lines, if you require a similar functionality, then create your own binary file format/editor, write your 'data' to it and read it back into arrays when required. This is the way most modern languages handle large blocks of reusable static data.

GLBasic can easily fill and array from a file or write one back to it...

Code (glbasic) Select
OPENFILE() WRITEBYTE(), WRITEWORD(), WRITEWORD(). WRITEIEEE(), WRITESTR(), WRITELONG(), CLOSEFILE()

OPENFILE(), READBYTE(), READWORD(), READIEEE(), READSTR(), READLINE(), READLONG(), CLOSEFILE()
Quicker to compile, more compact, portable and you don't waste dynamic memory with two copies of the same data (1 in the array and one sitting as a reference).
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Brice Manuel

I have always preferred not to store data externally ;)  For me, read/data/restore is part of what makes a BASIC a BASIC.

I enjoy using GLBasic for prototyping.  Extremely easy to quickly get an idea up and running.

bigsofty

I actually prefer Pascal... simple as basic and powerful as C++... everyone has their ideal language I suppose. ;)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

shaf

I perferred the structuring of Pascal to Basic, COMAL had some interesting features and preferred Fortran for mathematics.

shaf

I think I understand how DIMDATA works but how would I use it for a 2 Dimensional array

What I've done currently is Split the array into multiple lines like so:

// --------------------------------- //
// Project: Tower of Mystery
// Start: Tuesday, November 06, 2007
// IDE Version: 5.062
//
// declare constants
//
// NR number of rooms
// NT number of things/items
// NP number of Pseudo-Objects (all other Objects)
// NO number of objects of all kinds
// NV number of verbs
//
// declare Flags
//
// CA Computer Active (in-game)
// CD Computer is Dead
// LI Character is logged into computer
// CP COPY of program is running on computer
// MF Computer Manual Found
// CF Coin Found
// WD Room description request flag
// RT Rats are Troublesome
// BT Bats are troublesome
// CT Time since computer was started
//
// General Variables
//
// C$  Command input
// C1$ First word of command
// C2$ Second Word of command
// C1  Verb token
// C2 Object token
// RM Room currently occupied
//
// Arrays
//
// AC[NR][6] Access Array
// VB$[NV] Verb array
// OB$[NO] Object Array
// RM$[NR] Room description array
// TD$[NT] Item description array
// VN[NV]  Verb token array
// TL[NT]  Item Location Array
// TF[NT]  Item Flag array (for can item be carried)
//
// Directions can be numeric or alpha
//
// 1 N  North
// 2 S  South
// 3 E  East
// 4 W  West
// 5 U  Up
// 6 D  Down
//
//
GLOBAL NR, NT, NP, NV, NO, RM, CT, CF, RT, CA, MF, CD, WD, LI, BT, VB$, OB$, RM$, TD$, VN, TL, TF
NR=14
NT=11
NP=11
NV=29
NO=NT+NP
DIM AC[NR][6]
DIM VB$[NV]
DIM OB$[NO]
DIM RM$[NR]
DIM TD$[NT]
DIM VN[NV]
DIM TL[NT]
DIM TF[NT]
// Initialization of Variables
RM= 1
CT= 0
CF= 0
RT= -1
CA= 0
MF= 0
CD= 0
WD= -1
LI= 0
BT= -1
FOR I = 1 TO NR
DIMDATA RM$[], "You are in the front of an old factory with a Clock tower." ,"You are at the bottom of a stairwell." ,"You are at the top of the basement steps." ,"You are in a damp cellar." ,"You are in a storeroom." ,"You are in the cafeteria." ,"You are at a landing on the stairs." ,"Around you is a manufacturing area." ,"You are at a landing on the third floor." ,"You are in the Computer room." ,"You are inside the Clock Tower." ,"You are at the top of the stairs." ,"You are in a long corridor going east." ,"You are at the east end of the corridor."
// DATA "You are in the front of an old factory with a Clock tower."
// DATA "You are at the bottom of a stairwell."
// DATA "You are at the top of the basement steps."
// DATA "You are in a damp cellar."
// DATA "You are in a storeroom."
// DATA "You are in the cafeteria."
// DATA "You are at a landing on the stairs."
// DATA "Around you is a manufacturing area."
// DATA "You are at a landing on the third floor."
// DATA "You are in the Computer room."
// DATA "You are inside the Clock Tower."
// DATA "You are at the top of the stairs."
// DATA "You are in a long corridor going east."
// DATA "You are at the east end of the corridor."
NEXT
FOR I = 1 TO NV
// READ VB$,VN;
DIMDATA VB$[], "N","S","E","W","U","D","GO","EAT","KICK","INSERT","DEPOSIT","TYPE","TAKE","GET","DROP","THROW","INVENTORY","I","INV","MOUNT","READ","FIGHT","KILL","START","POWER","OPEN","QUIT","LOOK","WIND","EXAMI","EXAMINE"
DIMDATA VN[], 1,2,3,4,5,6,7,8,9,10,10,11,12,12,13,13,14,14,14,15,16,17,17,18,18,19,20,21,22,23,23
// DATA N,1,S,2,E,3,W,4,U,5,D,6,"GO",7,"EAT",8,"KICK",9,"INSERT",10,"DEPOSIT",10,"TYPE",11
// DATA "TAKE",12,"GET",12,"DROP",13,"THROW",13,"INVENTORY",14,I,14,"INV",14,"MOUNT",15,"READ",16
// DATA "FIGHT",17,"KILL",17,"START",18,"POWER",18,"OPEN",19,"QUIT",20,"LOOK",21
// DATA "WIND",22,"EXAMI",23,"EXAMINE",23
 NEXT
FOR I = 1 TO NO;
// READ OB$;
DIMDATA OB$[], "RATS","TAPE","MACHINE","TERMINAL","COIN","CANDY","COMPUTER","BATS","DESK","MANUAL","CLOCK","ROAD","DIR","ADVEN","COPY","LOGOUT","NORTH","SOUTH","EAST","WEST","UP","DOWN"
// DATA "RATS","TAPE","MACHINE","TERMINAL","COIN","CANDY","COMPUTER","BATS","DESK","MANUAL","CLOCK","ROAD"
// DATA "DIR","ADVEN","COPY","LOGOUT","NORTH","SOUTH","EAST","WEST","UP","DOWN"
 NEXT
FOR I = 1 TO NT
// READ TD$,TL,TF
DIMDATA TD$[], "HUNGRY RATS", "COMPUTER TAPE", "VENDING MACHINE", "BROKEN-DOWN TERMINAL", "COIN", "CANDY BAR", "COMPUTER","BATS","DESK","COMPUTER MANUAL","ELABORATE CLOCKWORK"
DIMDATA TL[], 4,5,6,8,-1,-1,10,13,14,-1,11
DIMDATA FT[], 0,1,0,1,1,1,1,0,0,1,0
// DATA "HUNGRY RATS",4,0,"COMPUTER TAPE",5,1,"VENDING MACHINE",6,0
// DATA "BROKEN-DOWN TERMINAL",8,1,"COIN",-1,1,"CANDY BAR",-1,1,"COMPUTER",10,1
// DATA "BATS",13,0,"DESK",14,0,"COMPUTER MANUAL",-1,1,"ELABORATE CLOCKWORK",11,0
 NEXT
FOR I = 1 TO NR
// READ AC[1],AC[2],AC[3],AC[4],AC[5],AC[6]
// DIMDATA AC[NR][6], 2,0,0,0,0,0,3,1,0,0,7,0,0,2,0,0,0,4,0,0,5,0,3,0,0,0,0,4,0,0,0,0,7,0,0,0,0,0,10,0,12,7,0,0,0,9,0,0,0,12,0,0,0,0,11,0,13,0,0,9,0,0,14,12,0,0,0,0,0,13,0,0
DIMDATA AC[], 2,3,0,0,0,0,0,0,0,0,0,11,0,0
DIMDATA AC[], 0,1,2,0,0,0,0,0,0,0,12,0,0,0
DIMDATA AC[], 0,0,0,5,0,7,8,0,10,0,0,13,14,0
DIMDATA AC[], 0,0,0,0,4,0,6,7,0,9,0,0,12,13
DIMDATA AC[], 0,7,0,3,0,0,9,0,12.0,0,0,0,0
DIMDATA AC[], 0,0,4,0,0,0,2,0,7,0,0,9,0,0
// DATA 2,0,0,0,0,0
// DATA 3,1,0,0,7,0
// DATA 0,2,0,0,0,4
// DATA 0,0,5,0,3,0
// DATA 0,0,0,4,0,0
// DATA 0,0,7,0,0,0
// DATA 0,0,8,6,9,2
// DATA 0,0,0,7,0,0
// DATA 0,0,10,0,12,7
// DATA 0,0,0,9,0,0
// DATA 0,12,0,0,0,0
// DATA 11,0,13,0,0,9
// DATA 0,0,14,12,0,0
// DATA 0,0,0,13,0,0
 NEXT

bigsofty

Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)