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.

AppGameKit Studio Chat / [SOLVED] Call a function from its name in a string

Author
Message
XANAX 2B
19
Years of Service
User Offline
Joined: 20th Jun 2003
Location: Corsica (France)
Posted: 24th Nov 2022 16:02
Hello,

Is it possible to do such a thing :

Emotional High Potential

The author of this post has marked a post as an answer.

Go to answer

Steve Ancell
17
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 24th Nov 2022 16:10
This post has been marked by the post author as the answer.
Not as far as I know.
Ortu
DBPro Master
15
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 31st Jan 2023 03:44
it's not elegant but you can do it with a select case inside a helper function
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Steve Ancell
17
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 31st Jan 2023 16:44
Here's how I approach that kind of thing.

Kevin Picone
20
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 1st Feb 2023 00:05 Edited at: 1st Feb 2023 01:57
as has been suggested some type of "select case" block to catch the callable functions will get you there.

One extension to the such an idea would be to write a program that skims through your source code looking for functions that fit a particular pattern. I generally use a group name for such functions, you can just load the file into a string/array and do a bunch of searches on the strings looking for the ket, when you find it, find the next open bracket and then grab than name ans paste it into a select block.


Mock up library code



Here's an example (in PlayBASIC, but it's basically just some string operations.. following the concept should be easy enough)


This example loads itself, searches for the functions with function UCF_ if it finds any, it grabs the name and makes a simple case statement with function call. When all of the functions have been found the newly create code is inserted back into a template function. From here you would save this to disc for inclusion within your actual program. But in this example I've dump the text to the debug console in PB.






Example of the create caller code:




PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code

Login to post a reply

Server time is: 2023-03-23 08:31:00
Your offset time is: 2023-03-23 08:31:00