🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Storing Commands in Strings

Started by
2 comments, last by mldaalder 20 years, 11 months ago
Hello all, I am making a game (just as introduction) called Science Fiction Career. And I intent to make it (very) moddable. I use Visual Basic 6 Enterprise Edition, but I am willing to do this in an other way. Currently I am stuck at this part: I want to store commands in strings and execute the strings. Storing would be like this: ' Begin of Code Public Commands(1, 1023) As String Public NumCommands As Integer NumCommands = 1024 Commands(0, 0) = "Test" ' This is the Sub name Commands(1, 0) = "Dim i As Integer" & vbCrLf & "i = 9" & vbCrLf & "For i = 0 to i" & vbCrLf & " Form1.Print "Test Round: " & Cstr(i) & vbCrLf & " Form1.Print "It works!" & vbCrLf & "Next i" ' End of Code Executing would be like this: ' Begin of Code Public Sub ExecString(Name As String) Dim i As Integer For i = 0 to NumCommands If Commands(0, i) = Name Then SomeFunction(Commands(1, i) Exit Sub End If Next i End Sub Now the only thing that I need to know what SomeFunction would be the correct function is. I am using Visual Basic 6 Enterprise Edition If it can't be done in Visual Basic then please tell me a language in which it can (plus the correct function) and how I can use it with Visual Basic. Or with a DLL through C++ (if this is how it is done then please tell me which project type I need to open in Visual C++ 6 Enterprise Edition). Thanks for your time, mldaalder [edited by - mldaalder on July 25, 2003 1:42:25 PM]
Advertisement
I believe there is an article covering this sort of thing in our Articles and Resources section. Try the top part of this article, and preferably read the whole series.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]
I already tried that one, but it doens''t do what I want (I still need to hard code all my functions, this is something I wish to prevent).

And if I would do this in Visual C++ (I now hold the basics of it)?

Creator of: Science Fiction Career
Percent finnished: 0.1%

Site: comming soon
Forum: comming soon
Sorry for the double post but:

Something similar is the Lua scripting code, but that is written in C and I need C++. I know that they are similar, but I don''t want to add commands to the parser of Lua.

This topic is closed to new replies.

Advertisement