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.

Code Snippets / [DBP] parsing a function (e.g. for scripting)

Author
Message
RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 15th Apr 2008 19:03 Edited at: 15th Apr 2008 19:12
I just worked on parsing stuff like

text('Lol',50,50)

from a text file and felt like sharing my code...

The functions:

EXT_name(string$) => will extract the function name, e.g. 'text'
EXT_count(string$) => will count the parameters, e.g. 3
EXT_param(string$,pos) => will extract the specific parameter, e.g. 'Lol'

Example code: (needs matrix1utils, mainly because of Instr)


I hope anyone will find it useful

Edit: just saw that matrix1utils already contains a "string count(...)" function, so i removed my own version from the code

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 15th Apr 2008 22:19
That's great man. When you put in the small amount of effort to come up with something like this, you get a very simple and elegant solution to doing actions externally. Nice

Don't you just hate that Zotoaster guy?
calcyman
17
Years of Service
User Offline
Joined: 31st Aug 2007
Location: The Uncertainty Principle
Posted: 18th Apr 2008 21:17
Quote: "you get a very simple and elegant solution to doing actions externally."


I've used a similar system for actions in external data files. I found that the program becomes much more flexible if you allow people to type conditional statements into the script.

Here's an instr function for people who don't like plugins:



So now you can eliminate the need for a plugin in your code

The optomist's right, The pessimist's right.
RedFlames
17
Years of Service
User Offline
Joined: 25th Aug 2007
Location: Germania
Posted: 19th Apr 2008 02:17 Edited at: 19th Apr 2008 02:37
Quote: "So now you can eliminate the need for a plugin in your code"


yeah except the mid$(s$,start,size) and string count(Source$,Search$)
but i think i'll make/find a function for that too... will post updated codes soon...

Ok here is the no-plugin-code:


update original code:


Added rem_quote(s$) to remove qutoes from e.g. 'lol' or "lol" (if there are any)

Login to post a reply

Server time is: 2024-11-25 03:01:46
Your offset time is: 2024-11-25 03:01:46