Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Some questions of STR$, VAL, commas, semi colons & EXECUTE FILES commands...

Author
Message
Iron Maiden
20
Years of Service
User Offline
Joined: 27th Dec 2004
Location:
Posted: 31st Dec 2004 09:22
Ok, I have just read chapters 1-3 from the beginner's book and I am still having a little trouble understanding.

Alright, lets start with the commands STR$ & VAL.

I know what they do, but how exactly are they used and how useful are they? An example would really help.

Next is the difference between commas (,) & semi colons (.

What exacly is the difference? For example if I were to write this in a program:



I then execute the program and I get:

The answer is 4

Now if I were to write the above code but just add a semicolon:



I'd get:

The answer is 4

I see no difference in using a comma or a semi colon. How are each useful? When do I know which to use? An example would be nice.

FINALLY, the EXECUTE FILES. Exactly how are they helpful. How can the command be used in a program? An example would help me on this command which I have no understanding of.

Sorry if I ask the simplest stuff, I am a newbie after all and I want to learn.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 31st Dec 2004 10:13
ok 1st off i dont use the print command often so i wouldent know about the , or ; "things" your having, use the text command saves having to set the cursor every time.

execute file command is usefull say if you made a goto my website button, when you click it make it execute internetexplorer.exe or something and for the command like you would have the url or the site you wish to goto, or for notepad just point it to notepad.exe and command line something like, c:/test.txt and it will open it up in notepad.

if you wish to run a program made in db/p using the execute file + a command line, then start your program with

command_line$=cl$

cl$ is the command to retrieve the command line the program was executed with, so if you wanted to make your very own notebook, then save a file call it test.text and when you click it direct it to your exe, and it will execute your program and the command_line$ string will be the file location of your test.text.


hyrichter
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 31st Dec 2004 11:12
The str$ and val functions are used to convert between string and numeric text. For example, if you want to print the current frames per second to the screen, the following code will NOT work:

text 0,0, screen fps()

This is because "screen fps()" is a NUMERIC value, and the text command expects a string value. So you have to use the chr$ function to convert it into a string. So this code would work:

text 0,0, str$(screen fps())

Now, let's look at this the other way around. Suppose you have a string of data (this could come from a file of saved game info, or whatever). However, this string is a number and you want to add or multiply it to something. You will need to convert the string to a numeric value for it to work properly. Quick example:

myString$="123"
myNumber=val(myString$)
myNumber=myNumber * 2


I'm not totally sure about the difference between using a comma and a semicolon, but I believe that a semicolon keeps your cursor at the same position while a comma acts sort of like a tab character.

Dot Merix
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Canada
Posted: 31st Dec 2004 12:55
The semi colon etc makes it stay on the same line i believe, where as leaving it without the semi colon will pop the next print command to the next line.. I think.



WindowsXP Home(Service pack 2), Athlon XP 2400+(2.1Ghz), 1GIG Ram, Ati Radeon 9800Pro 128MB.
Iron Maiden
20
Years of Service
User Offline
Joined: 27th Dec 2004
Location:
Posted: 31st Dec 2004 13:44
Great! I am understanding the STR$ and VAL command. The EXECUTE command is still a bit rather hard to understand. I have to be the worst newbie this board has encounter.

As for the comma and semicolon, I still have no clue what the difference is.

Thanks a lot though for those who tried to explain EXECUTE FILE and the diff between comma & semicolons.

I hope someone out there can explain the EXECUTE FILE and the diff between commas & semicolon a bit more. I appreciate the feedback.
BigDan256
21
Years of Service
User Offline
Joined: 29th Oct 2003
Location: NSW, Australia
Posted: 31st Dec 2004 16:12
The print command has is a special case command in db, it's usage is roughly copied from the older versions of basic, like qbasic

the semi-colon is used to continue printing...

Should print "Hello" and then print " World" and then move the cursor to the next line

By putting the semi-colon on the end of the line, you signal that you want to keep the cursor after the "d"


Now the comma does the same thing except for one thing, it inserts a tab character, try this:

Hopefully the numbers after the comma should line up vertically. The comma is useful for a quick and cheap way to line up text like this

Login to post a reply

Server time is: 2025-05-24 07:51:31
Your offset time is: 2025-05-24 07:51:31