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.

Newcomers DBPro Corner / How to use mid$ command?

Author
Message
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 5th Aug 2003 01:03
hi,
i'm working on a FPS and I want to put an multiplayer option in it. I want to send a packet in this format:



which will be recieved by the the other PC's as i.e:

packet1$="mussi"+"*"+"1.0"+"*"+"1.0"+"*"+"2.0"

how can i seperate that data using the mid$ command?
Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 5th Aug 2003 01:17
You'll need something like this :

dim d$(4)

index=0
for x=1 to len(s$)
if mid$(s$,x)="*"
d$(index)=left$(s$,x-1)
s$=right$(s$,len(s$)-(x+1))
inc index
endif
next x

I haven't tested it, but what should happen is that d$(x) will contain each of the 4 sections, and s$ is modified so that the next section is first. Ie something like :

mussi*1.0*1.0*2.0
1.0*1.0*2.0
1.0*2.0
2.0


Logo design by Indi
Its better than a poke in the eye...
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 5th Aug 2003 23:24 Edited at: 6th Aug 2003 02:04
I tried to test that code with the following code but it doesn't works, it only prints the first data :/, here's the code:



I see your point mrTATOAD but don't know how to solve this, so can some1 help me out here?

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 6th Aug 2003 16:44
the prob is that I only get the first line :/
some1 knows a solution for this?

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 6th Aug 2003 16:57 Edited at: 6th Aug 2003 16:59
Hmm, maybe a better VB style MID$ would help?

Try this function, not tested.



Note that it will probably assume 0 as the first character, as opposed to the usual 1. Ohh, and in VB the mid$ command lets you specify the length of the text, so MIDS$("Monkey",3,3) would be "key"


Van-B

My cats breath smells of cat food.
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 6th Aug 2003 17:06
I'll try it when I get home - see what needs changing...


Logo design by Indi
Its better than a poke in the eye...
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 6th Aug 2003 20:51
Try this :




Logo design by Indi
Its better than a poke in the eye...
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th Aug 2003 03:27
Shameless plug:

A large collection of string commands (including a proper Mid$(), ColourText() and INSTR$()) are in my string function collection which you can get from the Downloads page at http://www.matedit.com.

It was written for DBC, but you should be able to lift out most if not all for use in DBP if that's what you are using.

TDK
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Aug 2003 10:59
And I do to at http://www.codingarea.co.uk


Logo design by Indi
Its better than a poke in the eye...
Mussi
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 7th Aug 2003 15:57
THNX all you guys, you guy's really helped me a lot

Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb ddr sdram

Login to post a reply

Server time is: 2026-07-06 20:15:57
Your offset time is: 2026-07-06 20:15:57