Qbasicnews.com
March 29, 2020, 09:52:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Problems problems problems  (Read 2044 times)
Yarik
New Member

Posts: 5


« on: July 18, 2003, 05:27:30 PM »

I am new to programing.  And when I try to do this

Code:
PRINT "setcvar "g_obj_alliedtext1" "Stalingrad" "

I keep getting an error.  Its absoultly nesseray that the text looks like this
Code:
setcvar "g_obj_alliedtext1" "Stalingrad"

But I dont know how to do it with QBASIC.
Here is my code so far.

Code:
CLS
INPUT "What is your map name"; MapName$
INPUT "What is your name"; YourName$
INPUT "1)Allied Text:", AT1$
INPUT "2)Allied Text:", AT2$
INPUT "3)Allied Text:", AT3$
INPUT "1)German Text:", GT1$
INPUT "1)German Text:", GT2$
INPUT "1)German Text:", GT3$
INPUT "Score Board Pick name:", SBP$
PRINT
PRINT
PRINT ".......Proccesing........"
PRINT
PRINT
PRINT
PRINT
PRINT
PRINT "Copy the SCRIPT below and call it"
PRINT "[YOURMAPNAME.SCR]  You dont need the []"
PRINT
PRINT
PRINT
PRINT
PRINT "//", MapName$
PRINT "//Map by ", YourName$
PRINT "//Scripting by Yarik"
PRINT "Main:"
PRINT
PRINT "// set score board messages"



After the last print this command
Code:
PRINT "setcvar "g_obj_alliedtext1" "Stalingrad" "

Keeps giving me errors.  What should I do?
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: July 18, 2003, 05:45:53 PM »

The problem is that QB gets puzzled with the first " in your text, as it understands that the string you want to print has ended.

To print quotes you need to use the CHR$ function which takes an ASCII number and returns the correspondent character. The quote is at 34, so you can use both

Code:
PRINT "setcvar " + CHR$(34) + "g_obj_alliedtext1" + CHR$(34) + " " + CHR$(34) + "Stalingrad" + CHR$(34) + " "


or

Code:
PRINT "setcvar "; CHR$(34); "g_obj_alliedtext1"; CHR$(34); " "; CHR$(34); "Stalingrad"; CHR$(34); " "


Check QB help for PRINT and CHR$ to understand the command syntax.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Yarik
New Member

Posts: 5


« Reply #2 on: July 18, 2003, 07:05:52 PM »

Quote
Check QB help for PRINT and CHR$ to understand the command syntax

Can you zip it up and send it to me?  I dont have the help file.
Logged
Yarik
New Member

Posts: 5


« Reply #3 on: July 18, 2003, 08:12:35 PM »

It now says Subscript out of range.  And I tried your first option.

.....

Ok  at the top of the script they have an option for allied text.

So I want it to print

setcvar "g_obj_alliedtext1" "Stalingrad"  

But instead of stalingrad I want the input for the text that they did
So something like this

setcvar "g_obj_alliedtext1" "AT1$"  
So what ever they typed in for AT1$ it will give them there name.
Logged
oracle
*/-\*
*****
Posts: 3652



WWW
« Reply #4 on: July 18, 2003, 08:43:08 PM »

You don't enclose variable names in quotes in QBasic. There is no escape handling. This is what you do:

Code:
PRINT "setcvar " + CHR$(34) + "g_obj_alliedtext1" + CHR$(34) + " " + CHR$(34) + "Stalingrad" + CHR$(34) + " " + AT1$


If I am understanding the question right...
Logged

toonski84
__/--\__
*****
Posts: 2567



« Reply #5 on: July 18, 2003, 08:46:23 PM »

if you dont have the help files take a gander at that "qboho" link up top Smiley
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #6 on: July 18, 2003, 10:13:49 PM »

Subscript out of range? I tried the code before sending it to you, and it just prints this text on screen:

Code:
setcvar "g_obj_alliedtext1" "Stalingrad"


so it just works fine  :Huh:
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!