Hi.
I'm quite a newbie in qbasic and wanted to find a quick and fast way to write a game that would run on user submitted scripts.
I was going through the Nightwolf Productions scripting tutorial (From QBtimes issue 1) when I realise there is no output to screen when I run the program.
The problem do not seem to be my windowxp's setting as I was able to "PRINT" to screen.
Does anyone have any idea what could have went wrong?
Nightwolf Productions's scripting tutorial
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
SCRIPTS? What are you trying to do? Post some code...........and explain the objective.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
I was following the script in the QB times...
See the code below.
See script.dat below.
What I wanted to do was to write a program which reads from a file and execute some orders, like in a pbem game. I stumble upon the QB times issue which teaches the use of scripts to read input and execute it.
Following the tutorial gives no errors. But I was not able to see any output in the screen when I "run" the code.
When I write:
PRINT "Hello World"
in the above code below "PRINT Temp1$" it works fine.
See the code below.
Code: Select all
OPEN "script.dat" FOR INPUT AS #1
DO
INPUT #1, ReadLine$
ReadLine$ = LTRIM$(RTRIM$(ReadLine$))
IF LEFT$(ReadLine$, 11) = "DISPLAYTEXT" THEN
Temp1$ = RIGHT$(ReadList$, LEN(ReadLine$) - 12)
PRINT Temp1$
END IF
IF LEFT$(ReadLine$, 7) = "WAITKEY" THEN
WHILE INKEY$ = "": WEND
END IF
IF LEFT$(ReadLine$, 9) = "ENDSCRIPT" THEN
EXIT DO
END IF
LOOP UNTIL EOF(1)
CLOSE #1
Code: Select all
CLEARSCREEN
DISPLAYTEXT Wow! This is my first scripting language!!
DISPLAYTEXT Press any key to end...
WAITKEY
DISPLAYTEXT You pressed a key and now the program ends!
ENDSCRIPT
DISPLAYTEXT This action will NOT be executed because there
DISPLAYTEXT is an ENDSCRIPT command before it!
Following the tutorial gives no errors. But I was not able to see any output in the screen when I "run" the code.
When I write:
PRINT "Hello World"
in the above code below "PRINT Temp1$" it works fine.
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Try LINE INPUT #1, ReadLine$ and it should work. I gather you used PRINT #1 to create the file. LINE INPUT in both forms, creates a string variable. One with quotation marks on each end. So you need to use VAL for number values if you need them.
Also CLEARSCREEN would just use CLS
ENDSCRIPT could just end a program immediately with CLOSE: SYSTEM
CLOSE will close any OPEN files and, if not needed, can be used anyhow without an error.
SYSTEM allows a BAS file to run from the command line or a batch file without returning to the QB IDE. END or nothing at the end of the program will return to the IDE !
Also you could use INSTR(text$, search$) to find the print text start position and any Text to print. You search for a space after the Script command to find any print text. If 0 is returned, there is no space, thus no print command!
Ted
Also CLEARSCREEN would just use CLS
ENDSCRIPT could just end a program immediately with CLOSE: SYSTEM
CLOSE will close any OPEN files and, if not needed, can be used anyhow without an error.
SYSTEM allows a BAS file to run from the command line or a batch file without returning to the QB IDE. END or nothing at the end of the program will return to the IDE !
Also you could use INSTR(text$, search$) to find the print text start position and any Text to print. You search for a space after the Script command to find any print text. If 0 is returned, there is no space, thus no print command!
Code: Select all
SpacePosition% = INSTR(ReadLine$, " ")
IF SpacePosition% > 0 THEN
PrintPosition% = SpacePosition% + 1
IF PrintPosition% < LEN(ReadLine$) THEN PRINT MID$(ReadLine$, PrintPosition%, (LEN(Readline$) - PrintPosition%) + 1)
END IF
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
-
- Veteran
- Posts: 185
- Joined: Mon Jun 30, 2008 4:10 pm
lol
write a game in QB, who-du thunk it..
-
- Veteran
- Posts: 185
- Joined: Mon Jun 30, 2008 4:10 pm
Re: Nightwolf Productions's scripting tutorial
I am using this same script method in a program and am wondering if anyone had any ideas on a script language it's self?
is there some standard it is better to follow?
I mean the example used DISPLAYTEXT to correspond to the qb print but the displaytext command could just as well be "wetdog"..
I see we have freedom, but is there a standardized group of "preferred" commands to use?
is there some standard it is better to follow?
I mean the example used DISPLAYTEXT to correspond to the qb print but the displaytext command could just as well be "wetdog"..
I see we have freedom, but is there a standardized group of "preferred" commands to use?