Welcome to City-Data.com Forum!
U.S. CitiesCity-Data Forum Index
Go Back   City-Data Forum > General Forums > Science and Technology > Computers
 [Register]
Please register to participate in our discussions with 2 million other members - it's free and quick! Some forums can only be seen by registered members. After you create your account, you'll be able to customize options and access all our 15,000 new posts/day with fewer ads.
View detailed profile (Advanced) or search
site with Google Custom Search

Search Forums  (Advanced)
Reply Start New Thread
 
Old 06-12-2011, 07:38 PM
 
22,653 posts, read 24,571,809 times
Reputation: 20319

Advertisements

Please help me, I am coming up with and error message when I run a little program I am writing.

Here is the error message I get when I run the program:

"Expected, a label, variable or instruction."



Here is where the error message come form in the program******


DEBUG " Your time was ", DEC TimeCounter, ' Display time measurement.
" ms. ", CR
**** " To play again, hold the ", CR, ' Play gain instructions.
" button down again.", CR, CR


Thanks!!!
Reply With Quote Quick reply to this message

 
Old 06-13-2011, 08:46 AM
 
8,408 posts, read 7,400,755 times
Reputation: 8742
Quote:
Originally Posted by tickyul View Post
DEBUG " Your time was ", DEC TimeCounter, ' Display time measurement.
" ms. ", CR
**** " To play again, hold the ", CR, ' Play gain instructions.
" button down again.", CR, CR


Thanks!!!
Not familiar with PBasic but I do write in VB.Net. The single quote character is used to denote a comment. The red text in your code above is considered comments.

You appear to be inserting comments in the middle of a DEBUG statement. That's usually not allowed. Also, there appears to be a missing comma after the first CR in the debug string.
Try this instead:

' Display time measurement and Play Again instructions
DEBUG " Your time was ", DEC TimeCounter," ms. ", CR, " ms. ",
" To play again, hold the ", CR, " button down again.", CR, CR

Finally, I would question the use of DEBUG as opposed to some other I/O method for interaction with the user (either a msgbox or a console.write or something along those lines).
Reply With Quote Quick reply to this message
 
Old 06-13-2011, 11:06 AM
 
3,464 posts, read 4,834,647 times
Reputation: 7016
I have programmed in regular BASIC which PBasic is based off of but it has been ages ago so its hard to remember the commands and syntax off of the top of my head but just looking through your code snippet I agree with djmilf.

I would insert the missing comma and remove the comments within the block. Try running it again and if no errors, put your comments before the block of code and run it once more to make sure you didn't introduce any new errors.
Reply With Quote Quick reply to this message
 
Old 06-13-2011, 08:11 PM
 
22,653 posts, read 24,571,809 times
Reputation: 20319
Quote:
Originally Posted by djmilf View Post
Not familiar with PBasic but I do write in VB.Net. The single quote character is used to denote a comment. The red text in your code above is considered comments.

You appear to be inserting comments in the middle of a DEBUG statement. That's usually not allowed. Also, there appears to be a missing comma after the first CR in the debug string.
Try this instead:

' Display time measurement and Play Again instructions
DEBUG " Your time was ", DEC TimeCounter," ms. ", CR, " ms. ",
" To play again, hold the ", CR, " button down again.", CR, CR

Finally, I would question the use of DEBUG as opposed to some other I/O method for interaction with the user (either a msgbox or a console.write or something along those lines).
Thanks a lot. Pbasic does allow comments to the right of code, denoted with a '. Building a circuit along with the code, so debug is easiest. Cannot get through without that error, tried adding comma.

Thanks!
Reply With Quote Quick reply to this message
 
Old 06-13-2011, 08:13 PM
 
22,653 posts, read 24,571,809 times
Reputation: 20319
Quote:
Originally Posted by dijkstra View Post
I have programmed in regular BASIC which PBasic is based off of but it has been ages ago so its hard to remember the commands and syntax off of the top of my head but just looking through your code snippet I agree with djmilf.

I would insert the missing comma and remove the comments within the block. Try running it again and if no errors, put your comments before the block of code and run it once more to make sure you didn't introduce any new errors.

Thanks, tried that and still don't get through it. Pbasic allows comments to the right of code with a ' in front of comments.
Reply With Quote Quick reply to this message
 
Old 06-13-2011, 09:06 PM
 
Location: Wandering.
3,549 posts, read 6,660,964 times
Reputation: 2704
Quote:
Originally Posted by tickyul View Post
Please help me, I am coming up with and error message when I run a little program I am writing.

Here is the error message I get when I run the program:

"Expected, a label, variable or instruction."



Here is where the error message come form in the program******


DEBUG " Your time was ", DEC TimeCounter, ' Display time measurement.
" ms. ", CR
**** " To play again, hold the ", CR, ' Play gain instructions.
" button down again.", CR, CR


Thanks!!!
I'm not familiar with PBasic, but have a couple of suggestions:

try removing the comma from within the following quoted string:
" To play again, hold the " << Since the comma is used to concatenate lines in the debug statement, it may need some special escaping, but I'm not sure.

The other thing to look at is the inconsistent use of commas. I'd check the following:

" ms. ", CR << All of your other lines have commas after them, but this one doesn't (and just happens to appear before the error).
Reply With Quote Quick reply to this message
 
Old 06-13-2011, 09:57 PM
 
22,653 posts, read 24,571,809 times
Reputation: 20319
Quote:
Originally Posted by Skunk Workz View Post
I'm not familiar with PBasic, but have a couple of suggestions:

try removing the comma from within the following quoted string:
" To play again, hold the " << Since the comma is used to concatenate lines in the debug statement, it may need some special escaping, but I'm not sure.

The other thing to look at is the inconsistent use of commas. I'd check the following:

" ms. ", CR << All of your other lines have commas after them, but this one doesn't (and just happens to appear before the error).
Thanks, I have been playing with it, sentence structure is not that important. I'm kinda at a loss, moving commas and everything else aint doing it.
Reply With Quote Quick reply to this message
 
Old 06-14-2011, 05:01 AM
 
Location: Wandering.
3,549 posts, read 6,660,964 times
Reputation: 2704
Quote:
Originally Posted by tickyul View Post
Thanks, I have been playing with it, sentence structure is not that important. I'm kinda at a loss, moving commas and everything else aint doing it.
I don't have a board or I'd jump in a bit further here!

Several samples that I've seen follow the same syntax where they use a new Debug statement on each line, and end without a comma.

Give this a shot:

DEBUG " Your time was ", DEC TimeCounter ' Display time measurement.
DUBUG " ms. ", CR
DUBUG " To play again, hold the ", CR ' Play gain instructions.
DUBUG " button down again.", CR, CR
Reply With Quote Quick reply to this message
 
Old 06-14-2011, 06:32 AM
 
8,408 posts, read 7,400,755 times
Reputation: 8742
Quote:
Originally Posted by tickyul View Post
Thanks a lot. Pbasic does allow comments to the right of code, denoted with a '. Building a circuit along with the code, so debug is easiest. Cannot get through without that error, tried adding comma.

Thanks!
Yes, all versions of Basic allow comments to the right of the code - but they don't allow a comment within a statement.

A Debug is like a subroutine call and the items after the word DEBUG are like parameters. You're breaking up the parameter list when you allow a DEBUG statement to run on several lines and add comments to the right. The Basic interpreter will see it all as one line terminated by a comment.

Did you try it without the comments and with the correct number and placement of commas?
Reply With Quote Quick reply to this message
 
Old 06-14-2011, 06:42 PM
 
22,653 posts, read 24,571,809 times
Reputation: 20319
Quote:
Originally Posted by Skunk Workz View Post
I don't have a board or I'd jump in a bit further here!

Several samples that I've seen follow the same syntax where they use a new Debug statement on each line, and end without a comma.

Give this a shot:

DEBUG " Your time was ", DEC TimeCounter ' Display time measurement.
DUBUG " ms. ", CR
DUBUG " To play again, hold the ", CR ' Play gain instructions.
DUBUG " button down again.", CR, CR

Thanks a lot, your suggestion was very close.

Here is the code that worked, basically your suggestion without the "Debug" command in every line (tried that and came up with error messages).

DEBUG " Your time was ", DEC TimeCounter, ' Display time measurement.
" ms. ", CR,
" To play again, hold the ", CR, ' Play again instructions.
" button down again.", CR, CR


LOOP



thanks a lot.
Reply With Quote Quick reply to this message
Please register to post and access all features of our very popular forum. It is free and quick. Over $68,000 in prizes has already been given out to active posters on our forum. Additional giveaways are planned.

Detailed information about all U.S. cities, counties, and zip codes on our site: City-data.com.


Reply
Please update this thread with any new information or opinions. This open thread is still read by thousands of people, so we encourage all additional points of view.

Quick Reply
Message:

Over $104,000 in prizes was already given out to active posters on our forum and additional giveaways are planned!

Go Back   City-Data Forum > General Forums > Science and Technology > Computers
Similar Threads

All times are GMT -6. The time now is 05:19 PM.

© 2005-2024, Advameg, Inc. · Please obey Forum Rules · Terms of Use and Privacy Policy · Bug Bounty

City-Data.com - Contact Us - Archive 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37 - Top