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 / Reading Strings

Author
Message
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 15th Jul 2003 03:28
i have loaded my strings, and want to figuire out a way to see if a letter/symbol is in the string. for instance, if string$(1) = "#J#" and i want to find out if a J is in the string, how would i do this? Is it even possible?
---Mattman
DID YOU KNOW THAT http://www.angelfire.com/vamp/epiccrossings/ILOVEDB.jpg[/img] ???
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 15th Jul 2003 04:06
Well, you could use the special text commands to find out what is in the string, print it in different forms etc. You could also write it to a text file, and scan that (there was a function round here somewhere...)

Cheers

RPGamer

Current Project: Eternal Destiny
Questions? Comments? Suggestions? Go to the Eternal Destiny Forum!
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 15th Jul 2003 04:13


Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 15th Jul 2003 04:39
thanks! that was exactly what i needed. now to finish my level editor...

---Mattman
DID YOU KNOW THAT ???
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 15th Jul 2003 17:56 Edited at: 15th Jul 2003 17:56
is there a way to read the first letter, than the next, and the next? so if my string was "###$###" i could read "#" then "#" then "#" then "$" etc.?

---Mattman
DID YOU KNOW THAT ???
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 16th Jul 2003 00:59
help

---Mattman
DID YOU KNOW THAT ???
MrTAToad
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 16th Jul 2003 01:13
You can do it like :



Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins and other exciting things - oh my, yes!
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 16th Jul 2003 07:16
Let me explain what i want to do:

I am creating a custom Level Creator for my game. As they are in a mansion and most levels are the same, it seems easy to do this. Like



at required times i would increase placex and placez.

Does this help anyone in helping me?

---Mattman
DID YOU KNOW THAT ???
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 16th Jul 2003 08:32
What?
There's no PLACE OBJECT command. POSITION OBJECT perhaps.
I think for level editors, it's best to use arrays if your game is tile-based like this. After all, a string is a type of array, but the elements are a little tricker to access. If you're using an array, the incremented variables in your for loop can be multiplied by the size of the object tile to determine the position to place the object.

Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 16th Jul 2003 16:18
oh ya. i get those mixed up. anyways, i am using arrays. that was not my actual code up there.

---Mattman
DID YOU KNOW THAT ???
Carlitos
21
Years of Service
User Offline
Joined: 8th Jul 2003
Location: United States
Posted: 16th Jul 2003 16:37
lol
"DUCK!!!"

(read his bio,lol)

--carlitos
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 16th Jul 2003 17:15
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 16th Jul 2003 19:47
how do i do one letter at a time?

---Mattman
DID YOU KNOW THAT ???
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 17th Jul 2003 02:17
bump

---Mattman
DID YOU KNOW THAT ???
Ag3ntSm1th
22
Years of Service
User Offline
Joined: 13th May 2003
Location:
Posted: 17th Jul 2003 08:10


"The secret to creativity is knowing how to hide your sources." - Einstein
my DarkBasic creations - http://www.sixurbanninjas.tk
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 17th Jul 2003 16:00 Edited at: 17th Jul 2003 19:16
So i would need a case for each symbol?

---Mattman
DID YOU KNOW THAT ???
k0shi
22
Years of Service
User Offline
Joined: 30th Dec 2002
Location: Cyberspace
Posted: 18th Jul 2003 07:14
i made this a while ago, never thought id use it ...
.. hey new smilies

famous last words-
Learn as if youll live forever, and give as if youll die tomorrow.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Jul 2003 00:25
If anyone wants a collection of string functions not found in DB, my string function collection is in the downloads section at http://www.matedit.com.

It has an INSTR function, (what's needed for the original post in this thread), a proper Mid$ function, a ColourText function and loads more.

TDK
Hamish McHaggis
22
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 19th Jul 2003 01:14 Edited at: 19th Jul 2003 01:15
I also have an instr() function, just for the sake of it...

Syntax = instr(string to be searched in, string to be looked for, nth occurence of string)

It returns the position of the string (that is the position of the first character of it) and 0 if it isn't found. The third parameter is used for different occurences. So if there was a string...

"hellomehellome"

and you said..

instr("hellomehellome", "me", 1)

It would return 6 as the 1st occurence is 6 characters along. However if you did ...

instr("hellomehellome", "me", 2)

Then it would return 13 as the second occurence of 'me' is 13 characters along.



cuRant PRogekt: a three-de map editer
Why the hell'd you ask me for crying out loud!?!
Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 19th Jul 2003 01:26
hmm, i'll take some lookies later.

---Mattman
DID YOU KNOW THAT ???

Login to post a reply

Server time is: 2025-05-19 09:53:32
Your offset time is: 2025-05-19 09:53:32