hi, im working on a simple script language, and so far i got it working great (with help from Athar, thanx again buddy). now one thing im having a little trouble with is taking text from the file, such as a line to print and formatting it to display the variables in the script. the way i was doing it was using the replace function from the string class (using the example for it on this site as a starting point) but it wasnt able to get it to work. i want to be able to format it in a similar way to the C/C++ printf function. thnks in advance.
it wasnt replacing the variables properly. i was getting it to search for a specific string like %d, %s and replacing it with the variables provided from the script. heres and example of a line from the script
printf;string to print. ran program %d time(s);int;ran
the int before the variable ran tells the script parser that the first variable to place in the string is an integer. now the problem isnt if theres one item to format, its when you have more than one.
until i have that little problem fixed i just have a function to print the variable by itself. but i would like to make it easier by having it all in one line of code in the script.
I am still not very clear on what you need, but here is some code showing how I might approach writing a string format parser. Perhaps you will find some of it useful:
that works wonders. i was able to intergrate that into my code, with no changes to the function code. just had to change how it added info to the value vector slightly, as im using string class variables for my parameters. but all in all, it works great. thanks for the help.