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.

Program Announcements / Regular Expressions in DBPro

Author
Message
adr
20
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 9th Apr 2006 16:29
What's this? Me, making a post in Program Announcements? April Fool's was last week so ... that must mean I've actually completed something.

If you're not familiar with regular expressions (and it would seem many people aren't) they're a way of doing complex pattern matching on a string. So, if you're sick and tired of using mid$ to parse configuration files, this plugin could be the answer.

If (like me) you're writing a quake-console where the user can type in commands and you need to parse them out, then this plugin would be invaluable.

Be warned that regular expressions, by their nature, aren't the speediest of things, so I wouldn't recommend calling this function once per sync. Not only that, but I'm not a very good c++ programmer (hooray for the vector class).

Just post in this thread if you want me to write a regular expression for you and I'll help where I can.

Go over to http://www.fuzzee.co.uk/site/dbp/ and download the 44k zip file of madness.

[center]
iv tryed everything!!!!!!!!!! could u please just add The gun and shooting Code thats All!!!!!!!!!
Hawkeye
20
Years of Service
User Offline
Joined: 19th Sep 2003
Location: SC, USA
Posted: 9th Apr 2006 17:29 Edited at: 9th Apr 2006 17:45
Nice plugin, and just when I start thinking about writing a console too


edit: andddd I'm already stuck. Is there a helpfile somewhere that tells you how to make those funky expression calls? I *think* I've figured out some of it, but a howto guide would be useful :/

edit again: what I'm trying to do is a basic noun/verb parser, so for example "shoot monstah" would return "shoot" and "monstah" and so then I can run various tests on those results...


I am but mad north north-west; when the wind is southerly I know a hawk from a handsaw - Hamlet, Hamlet
adr
20
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 9th Apr 2006 17:44 Edited at: 9th Apr 2006 17:51
consoles kick ass for ingame debugging - the only annoying thing is that you have to SELECT/CASE through *every* possible function and variable name to match it to its "real life" counterpart.

I'd give my left arm not to have to do that.

---

Quote: " Is there a helpfile somewhere that tells you how to make those funky expression calls"

Do you mean the bits like "([a-z]+)"? There are tutorials on the internet, just search for regular expressions. They come in two flavours, perl compatible and POSIX regular expressions. This plugin only supports posix expressions.

Describe what you're trying to do, and I'll show you how you make it. Unfortunately, regular expressions are a bit of a black art.

As an example, if you have the string "doFunction(true, 5, foobar)", then the regular expression to pull out the function name and the parameters would look like this (untested):

That says, get me an a-z string of one or more characters up until a left bracket... then match another string of 0 or more characters up until a right bracket.

You could then get clever, and do a regex split using the following one

That means split on a comma, and auto matically strip any white space after it.

[center]
iv tryed everything!!!!!!!!!! could u please just add The gun and shooting Code thats All!!!!!!!!!
Hawkeye
20
Years of Service
User Offline
Joined: 19th Sep 2003
Location: SC, USA
Posted: 9th Apr 2006 17:49
Aha, of course. Once again, google saves the day in about a half second


I am but mad north north-west; when the wind is southerly I know a hawk from a handsaw - Hamlet, Hamlet
spooky
21
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 9th Apr 2006 22:12
Regular expressions do take quite a while to learn but once you've been using them for many years like I have they are fantastic and save LOTS of coding. I don't see much of a need for them in DBPro games but I'll know where to turn when I need it.

Boo!
adr
20
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 9th Apr 2006 22:22
If you do manage to think of a use for them, let me know. I've already listed all the uses I can think of (both of them). It's gonna be handy for my in game debugging console .. but that's pretty much it.

[center]
iv tryed everything!!!!!!!!!! could u please just add The gun and shooting Code thats All!!!!!!!!!
Bmad6
18
Years of Service
User Offline
Joined: 25th Aug 2005
Location: Virginia, United States
Posted: 12th Apr 2006 00:27
Quote: "Do you mean the bits like "([a-z]+)"? There are tutorials on the internet, just search for regular expressions. They come in two flavours, perl compatible and POSIX regular expressions. This plugin only supports posix expressions."


I've done quite a bit of programming in Visual Basic, including extensive use of regular expressions. Do you know whether the special characters and things from Visual Basic are the same as the ones in this plugin?
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 12th Apr 2006 04:26
posix is cross platform iirc

adr, good job.
sorry I never added the input console to the dbp_netlib - we did talk about that, didnt we?

lol.

adr
20
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 12th Apr 2006 11:04 Edited at: 12th Apr 2006 11:07
Quote: "Do you know whether the special characters and things from Visual Basic are the same as the ones in this plugin? "

It depends if VB uses perl, posix, or (quite likely) an MS variant.
Special meta-characters like "\w" are not POSIX compatible characters, however stuff like [:alpha is. IIRC.

Quote: "adr, good job."

The annoying part of development was knowing how much easier this would be in managed c or c#. I'm glad I persisted though - very satisfying. I could go even further, and try to make the plugin smaller by not using the vector STL class. I don't fancy dynamic arrays of strings though. I'm seeing why plugin development is so popular around here; it's DBP-related, but with a real language.

Quote: "sorry I never added the input console to the dbp_netlib - we did talk about that, didnt we?"


Yeah - I've forgotten the functionality we discussed to be honest ...
Originally, it was just a quake-console input type thing. It would ease parsing out the command and parameters to the command. With this plugin and a bit of DBPro work, that's working out quite nicely.

I think one of the bigger ideas for the plugin is that you could "register" variables with the plugin from DBPro. Essentially, the variables are stored in the plugin under huge associative arrays and DBPro supports a netlib get float/string/int type function which reads it back in.

The cool part is that the plugin has a nice interface for altering variables and therefore, if DBPro is retrieving the values from the plugin, the behaviour of your app is altered immediately (in theory).

D'you know, I'm tempted to have a go at that... Maybe the interface could be "in-engine" ... BlueGUI? Or even a text console... hmm. ideas.

[center]
iv tryed everything!!!!!!!!!! could u please just add The gun and shooting Code thats All!!!!!!!!!
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 12th Apr 2006 15:54 Edited at: 12th Apr 2006 15:57
I actually made a stand-alone dll a while back called InputConsole which was this theory exactly (dbp reading in values from the console, affecting internal dbp variables and altering the dbp app behavior in real time) I used it to help ZK test his .net converter, and we did finally get the converter sorted, and I did end up with this plugin. It was never added to netlib because netlib was c++ wrapped, and using ZK's converter wrapping wasnt necessary. The plan was to move the netlib to converted version along with the new input console, but that fell thru when I noticed problems with another converted dll. I ended up stopping work on all this stuff because now I wasnt sure what the problem was (converter or my .net code). It has sort of remained in this state until recently actually. I have been writing a dll for .net to use with EZS and dgsdk.net, the basis of which was the converter version of the source code. I have discovered two coding errors in the area of zone client management, and this is just about where the dbp-converted version was blowing up, so I may have just proved that ZK's .net converter is fine and it was my source code that dying. There was no real way for me to know this was occurring until I took the code into a pure .net oop environment and was able to properly debug and test. Turns out an async method was stepping on another thread that was busy altering a Collection. Bad, very bad.

sorry to have rambled. I guess what I am saying is that converted plugins (.net to dbp) may be on the agenda again.

Your ideas sound good adr, keep up the good work - and yes working with dbp but from a real language is quite fun. I am also currently beta testing the DGSDK.NET for Apexnow. Its coming along nicely. Talk about an uber-rush: Game programming from vb.net (or c#) without having to incorp or learn a new engine, and having available proper debugging, the best ide's (vs 2003,2005), and all of .NET and Windows API's.

optical r
21
Years of Service
User Offline
Joined: 23rd Oct 2002
Location: Prime
Posted: 10th May 2006 16:21
adr, niceley achieved, been meaning to write something similar to this in ages. Thankyou!

Your signature has been erased by a mod because it's larger than 600x120...
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th May 2006 10:17
mysql error on download:

Access denied for user: 'nobody@localhost'


adr
20
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 13th May 2006 17:04 Edited at: 13th May 2006 17:20
Crap. I know what happened, but the MySQL error is not the problem. The actual file "Regex.zip" doesn't seem to exist on my server. I'm looking at some backups now.

...

Dammit - it wasn't on there 11 days after I released it! No wonder the forum's reaction was rather ... quiet.


--- EDIT: Ok, I'm making an appeal. If anyone did manage to download the .zip file, let me know. I cannot find a copy of the ZIP file anywhere. I've got the DLL, but the ZIP file had instructions and what-not.

[center]
iv tryed everything!!!!!!!!!! could u please just add The gun and shooting Code thats All!!!!!!!!!
adr
20
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 14th May 2006 01:38
Sorry for the bump, but now that the file can actually be downloaded reliably I feel like this deserves a re-release. I'm sorry to anyone who wanted to download it originally but couldn't. All I can ask is that you try now and let me know what sort of use you get out of it.

Thanks should to Hawkeye for being organised enough to keep a copy of the original zip file. In case you are wondering, I do still have the original source, but not the ini file and readme....

/me backs up the original zip.

[center]
iv tryed everything!!!!!!!!!! could u please just add The gun and shooting Code thats All!!!!!!!!!

Login to post a reply

Server time is: 2024-05-18 19:49:19
Your offset time is: 2024-05-18 19:49:19