Simple Script Language Questions

Simple Script Language Questions

Post by YayPython on Sat Feb 28, 2009 2:05 pm
([msg=18893]see Simple Script Language Questions[/msg])

I actually got a small script language working, all by myself. :D

However, there are a few things I would like to figure out:
1. To open a file, I get input (for the filename) and save it to a char variable. Then, I use an ifstream to open the variable. That works great. However, I want to make it so when you double click on a .hs file, it will automatically pass the file location to the char variable. When I double click on my .hs file, it opens the program and asks me where the file is. I just want it to bypass that step so you don't have to type that in if you opened the file, but I do want ti to do that if you just run the program. Is there a way to do this?

2. I want to make it so the interpreter completly ignores a line in the file if it beins with // (Comments.) I have it set up so it reads each word in the file, sends it to a huge array, and then a for loop reads the lines and checks to see if it's a command. Ex:
Psuedo code:
Code: Select all
lines[100000]
open file.txt
read file.txt
send lines to lines[]
for(i=0;i<20;i++){
if(lines[k] == "$dos()"){
  dos()
}
etc...
}


How can I make it ignore everythong on the line after the //? I'm not asking for code, maybe a few hints and a links or two.
User avatar
YayPython
Experienced User
Experienced User
 
Posts: 50
Joined: Sat Jan 31, 2009 11:05 am
Blog: View Blog (0)


Re: Simple Script Language Questions

Post by mischief on Sat Feb 28, 2009 5:31 pm
([msg=18913]see Re: Simple Script Language Questions[/msg])

first of all, if you are using C++, don't use chars unless it is appropriate for the situation.
second of all, if you are using C++, don't use arrays unless absolutely necessary.
third, in windows you should be able to associate a 'hs' file with your program by right clicking a .hs file, hit properties, and click the button to associate it with a program. then find the program, and then .hs files should attempt to open with it.
fourth. post some code so we can get an idea of what your issues are, and be more verbose.
The whole secret of existence is to have no fear. Never fear what will become of you, depend on no one. Only the moment you reject all help are you freed.
--Buddha
User avatar
mischief
Poster
Poster
 
Posts: 355
Joined: Wed Jan 07, 2009 4:16 pm
Blog: View Blog (0)



Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests