Running Code From A Text File?
ok, i would search for this - but i have no idea what to search for
i'm working on a text game - well thinking about it - and i came to wonder... anyone who makes mods for games like NWN or Morrowind will know what i mean - if you don't, hopefully i'm clear enough..
how would one make "scripts"... umm i don't know how to clearly explain it really - but it's like in the editor someone writes something similar to VB code - and it's compiled from a text file during the game.
for instance - in Morrowind you can write scripts on people in a C++ like language... where you do something like
Start Hello Script
if player.race=1 then npc.speak "hello elf" end if
end script
-that's not exactly how it works, it's just an example idea. i'm building up ideas to make the most open-ended Text based RPG ever... so i'm trying to figure out how to make it work
i'm thinking of writing a simple engine that takes these commands and executes them. so that VB doesn't read them itself - but my own little "script engine" does - that way i can make my own syntax and whatnot... VERY complicated sounding stuff to me - but i'm willing to put a lot of work into it. anyway - maybe someone could help me with a tutorial or something on how scripting in game editors like morrind or neverwinter nights works.
also - i'm what you would call a beginner in VB - although i've used it for a few years, i never really learned complicated functions - just the basic ones... so something well detailed would be appreciated. hopefully this is clear - thank you!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Getting A Code From A Text File And Running That Code At Runtime.
Hi,
Winamp avs plugins work this way. It reads the code from a .avs file and excutes it at runtime.
Do you know how to read a code from a text file and excute it at runtime.
for example.
C:windowsdesktop ext1.txt contains these lines.
______________
msgbox ("Hi")
unload me
______________
I want to read that file and excute that code at runtime with my programme.
Is it possible.
If it is please tell me how.
Regards,
Dasith
Running Code From A Text File
If i had a text file, called say code.txt, which had visual basic code in it, could I execute the code from the file during run time.
For example, when the main form loads, it first opens the text file and runs the code that is in the text file, then continues running as per normal.
Thanks.
Running Code From Text File.
I know there is a way to get a code for a certein object from a text file, I just forgot where I saw that infomation. How can this be done?
Also: Is there a way to run 1 line of code from a textbox?
Ex:
VB Code:
'Textbox text: Msgbox "Sup", vbOkonly Private Sub Command1_Click() 'runcode from textbox"End Sub
Stop Running Code Until Text File Is Closed
I first open a text file, update it and then want to repopulate a combobox with the modified contents of the file. Here's the code I'm using.
VB Code:
Private Sub cmdAddOperators_Click() Shell "NOTEPAD.EXE " & App.Path & "Operators.txt", vbNormalFocus Call UpdateOperators 'update comboboxEnd Sub Private Sub UpdateOperators() Dim sText As String cboOperator.Clear Open App.Path & "Operators.txt" For Input As #1 While Not EOF(1) Line Input #1, sText cboOperator.AddItem sText Wend Close #1 cboOperator.ListIndex = 0End Sub
How can I prevent making the call to update the combobox until after the user has closed the file?
Saving And Running Executable Code Using A Text File
I'm not quite a VB expert so if this question is dumb, forgive me. Is there any way that code can be built in a VB6 text file and later loaded as executable commands. I want to create a status file that stores the current vales of variables from a Class. I want to save the data together with the method call that would write the date back into the Class object when the text is executed. for example executing a piece of text such as
".SetID 123"
This would run the method SetID against a class and set the relevant variable to value 123.
Can someone help ?
Update Text Box Value Before Running Code
In Access 2000, I'm using a text box to manually enter a filename. The code takes the filename, locates an image on a network share, and displays the image. The problem is that the value in the text box doesn't update unless you press Enter after changing the value. How can I force the value to update?
Code:
Option Compare Database
Private Sub Label0_DblClick(Cancel As Integer)
Rem Declarations
Dim varDummy As Variant
Dim intDummy As Integer
Dim bolDummy As Boolean
Dim strPLN As String
Dim strFilename As String
Dim strCommandline As String
Rem Initialize Str
Rem Text1.SetFocus - doesn't update Text1.Value
strPLN = Text1.Value
strFilename = "\woelfel
etwrkshrd" + strPLN + ".jpg"
strCommandline = "C:Program FilesCommon FilesMicrosoft SharedPhotoEdPHOTOED.EXE " + strFilename
Rem Retrieve document
bolDummy = FExists(strFilename)
If bolDummy = True Then
varDummy = Shell(strCommandline, 1)
Else
intDummy = MsgBox("File does not exist", vbOKOnly)
End If
End Sub
Public Function FExists(OrigFile As String)
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
FExists = fs.FileExists(OrigFile)
End Function
Running .BAT File From VB.NET Code
I tried this code but it seems it doesn't work properly...
Vb.NET doesn't give me any error output but it seems that "file.bat" isn't executed...
I'm sure the batch file is ok because i tried double-click on it and it worked properly...
Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1
....
Dim hwnd As Long
hwnd = GetDesktopWindow()
ShellExecute(hwnd, "open", "C:FILE.BAT", _
vbNullString, vbNullString, SW_SHOWNORMAL)
....
Can anyone help me??!?!?!? PLEASE!!!!
How To Close A Running Exe File Using VB Code
I am an absolute beginner in using VB. I have used the following code to try to close a running exe file. But when I run it, there is an run time error '48' saying that File not found "User". Can anybody help me and point out what is the problem??
thanks in advance
Public Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
Public Declare Function PostMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Integer
Private Const WM_QUIT = &H12
Dim sTitle As String
Dim iHwnd As Integer
Dim ihTask As Integer
Dim iReturn As Integer
sTitle = "title"
iHwnd = FindWindow(0&, sTitle)
iReturn = PostMessage(iHwnd, WM_QUIT, 0, 0&)
Running A .EXE File From Withing VB Code
I'm a pretty novice VB user, and haven't had to do anything like this before, mostly familiar with simple forms and database access.
Anyways, I'm writing a small VB app that will act as an install program for another piece of software. It basically makes a directory, and copies some files over right now. What I'd like it to also do is run another setup.exe program and when that's done, put a shortcut on the desktop.
I don't really know where to even start looking. Is this API or ActiveX? Any help in just getting started would be appreciated.
Thanks,
Jake
What Different From Running From Source Code And Execute File???
I experienced problem that I don't understand or know why
If I run my program from VB appl. (start-> run). Results are coming OK. For example, after query to count record from a dba, it gives right number
Also from same program but after I generated into .exe file and run from it, the result of same above query give nothing and give no error or warning??
Could s/o explain???
Thanks
File Read Code Not Working While Running As Windows Service.. Pls Help Me Out
Hi , please help. I have done a small application to read a xml file and copy the requirement contents to another text file in a fixed format. all these need to be run as a windows service during specfic intervals.
the code is working when it is executed separately with out making as service. but when i place that code in a timer function and make the application as service, the file read code is not working. please help me out ... i need to submit this assigment today.
Need Running Userform/code To Handle Doubleclicking Of An Excel File In Win Explorer
I have the following rather complex Excel VBA problem:
I use a windows script to hide Excel, start it, open a workbook which autmatically shows a userform, making it look like it is a stand-alone application. I can also minimize the userform to system tray, having used the code from here:
http://www.xcelfiles.com/Userform_SystemTray.html
My problems then are:
- When I have the userform running (with excel hidden in the background), and then double-click an excel file in windows explorer or on the desktop, it fails to open the excel file since it tries to open it in the same instance as the userform, which seems to be preventing the file from opening until it is closed.
- When I minimize the userform to the system tray, it will open the excel file if i double-click it in windows explorer or on the desktop, but at the same time will unhide the excel instance and userform workbook, and when i then want to close the double-clicked excel file by closing excel, it of course also quits the userform workbook because they are running in the same instance
My 2 questions are:
1. Is it possible for a running userform to catch/realize that excel is trying to open an excel file that was double-clicked in windows explorer or on the desktop? The userform when restored seems to block the opening of a new file in the same instance. So it would be great if it could open that excel file in a new instance of excel, and any subsequent double-clicked excel files in that same new instance. Is something like that possible?
2. If not, is it possible, in the minimized state, for the userform to catch what file excel is opening and instead of opening it in the same instance, open it in a new instance (and subsequent excel files in that same new instance)?
Basically, I want the Userform workbook run in its own instance of excel and have any kind of excel files open in another, second instance.
Any genius have any bright ideas?
*Resolved*Running A Text File Through VB
Hey, i know this has already been answered, probly a million times, Ive searched this forum already for it and got this:
VB Code:
Open "C:Program FilesVB5filename.txt" For Input As #1
It opens the file but does not display it. How can I accomplish this simply? thanks
Importing And Running VB Methods From A Text File
Hi, i have a problem which may not be possible to achieve, but here it is.
I will write some VB code into a plain text file using Notepad. I then want my proper VB program to open the text file, get all the text from it, then run the VB code obtained in that text.
for example, I might have a plain text file called demo.txt which will contain the following data
VB Code:
Sub showMsg() MsgBox("this is a message")End Sub
Now, I want my VB program to open this text file, read the vb code in in, and then run it, thus popping up a message box telling me "this is a message".
Is this possible?
If not, here is another way I might be able to achieve the same result. Would it be possible to write the VB code as a module file instead and dynamically interperate it by my VB program. I don't want to have to link the program and the module together myself, I want the program to link to the module, run it, then unlink from it again.
This would achieve the same purpose, if possible. Are any of these 2 methods possible, and how would I go about coding this?
Thanks for all your help guys, it is very appreciated.
WATTO
watto@watto.org
http://www.watto.org
Open Text File In Running Instance Of TextPad
Hello.
(I think this is the correct forum for this post. If not, please let me know.)
I need to programmatically open a text file in TextPad. In my scenario, TextPad is already running, and I have found its window with the following:
CODEhWnd = FindWindow("TextPad4", vbNullString)
Not Running Finishing Code Until Another Program Quits Running.
ODes anyone know of a quick way to keep part of a vb program from running until another part is done.. Like for instance i want to run a Perl script from a VB program. but I don't want the rest of the VB program to run until after the Perl script is finished. I know of a way to do it but I don't want to put in all that extra code in unless I really really have to.. I know I can check to see what processes are running but I don't want to do that unless I have to.. any thoughts?
Match Text Box Value In Text File (complete Code Please)
i have text file like this
<B>john bredman</B><BR>
,SUMIT,TORONT,PENSIL,COMDEX,PERU,BANG
Phone: +92 (51)123-8784521<BR>
Fax: +92 (51)123-8784521<BR>
Email: <A href="mailto:ABC@hotmail.com"></A>
when i wirite in text box "john bredman" then it should search in text file and ignore "<B>,</B>,<BR>" and message appear that "string is found".
OR
if i write string "COMDEX" in text box and i press button to search in text file, if string is found in text file then message should appear that "string is found"
How Search Complete Value Of Text Box In Text File (some Code Please)
hi
some body please give me some code stuff for, when i enter a string value in text box then this value should be searched "as a whole word" in text file. or i clear this question that, when i enter in text box then all of the text box value should be match in text file.
thanks
How To Read A Text File That Conatains Asp Code Into An Another Asp File And Execute?
Hi,
I just want to know if there is something like the eval() function in ASP ........... I want to read a asp page into another as page using FSO .... and execute it .....
this is the code i now use
Code:
on error resume next
sPage = Request.QueryString("url")
Set filesys = CreateObject("Scripting.FileSystemObject")
path = server.MapPath(sPage)
Set filetxt = filesys.OpenTextFile(path, 1, True)
tl = filetxt.ReadAll
filetxt.Close
if len(tl) < 1 then
Response.write("File Not Found !")
End if
response.Write(tl)
now when I read a asp page using this code the page includes and the asp codes are not executed ........
How can I read and excute a ASP file .......
http://www.weareequal.org/goto_text.asp?url=Home
Regards,
Dasith
Code From Text File
Is thier a way to get some Visual Basic code from a text file and 'play' it?
CyberWil
P.S. If so, can someone make me a VB project file?
Writing In Text File With Code...
I'm trying to do an text editor (some people knows that)
I can read it... But I can't save the work... Don't tell me to use rich text box. I'm want to do an editor BY MY SELF... How can I do it? How can I save it? I use the same function in the template of vb. It calls Tip of Day (surely you know that in vb 6.0) . I use that functions in that template...
Reading Code From A Text File...
I want execute code from a text File, as if I cut the code out and pasted it into a text file. I've been looking around trying to find out how to do this, any help please?
Calling Code From A Text File
I was wondering how you would go about making a scripting system, where it takes a string from a textfile and then uses that string as though it was code. IE, in the text file there would be a line:
EV_SaveVideoOptions UTIL_SaveVideo
When a certain function in the program is called, it loads the text file and seaches for the string EV_SaveVideoOptions, and finds it associated with UTIL_SaveVideo. Stores UTIL_SaveVideo into a variable, IE:
Input #1, Command
(So command now = "UTIL_SaveVideo")
How can you then call that function, ie:
Call Command (which of course you can't do, since its a variable, not a function or sub), which would actually be calling Call UTIL_SaveVideo.
Any one know how to do this?
Runnign Code From Text File.
I know there is a way to get a code for a certein object from a text file, I just forgot where I saw that infomation. How can this be done?
Also: Is there a way to run 1 line of code from a textbox?
Ex:
Code:
'Textbox text: Msgbox "Sup", vbOkonly
Private Sub Command1_Click()
'runcode from textbox"
End Sub
Generate Code From Text File
Is there any way that I can take a text file (used to be a module, converted to a text file) and load it in to a program to have it read as if it were code instead of just strings?
Text File As Code. Posible?
Can you use a text file using the open "dir path" apend as #1
for code. like type
Title.ForeColor = "764578"
Label1.BackColor = "756357"
into the text file and it will act just like source code in the program say something like
Private Sub Form_Load()
Open "test.txt" For Append As #1
Do Until EOF(1)
Print #1, Text1.Text
Loop
Close #1
End Sub
And this be identical as
Private Sub Form_Load()
Title.ForeColor = "764578"
Label1.BackColor = "756357"
End Sub
What's Wrong With This Text File Code?
Ok here's the code ive got for storing a variable in a text file and then printing the contents of that variable into a text box.
VB Code:
Private Sub cmdSave_Click()'creates file in my documentsOpen "c:My documentsUsername.txt" For Append As #1Close #1 'puts the variable Usrename into the text fileOpen "c:My documentsUsername.txt" For Append As #1Print #1, UsernameClose #1 End Sub Private Sub cmdPrint_Click() 'prints the contents of the file username.txt into the text boxOpen "c:My documentsUsername.txt" For Append As #1Print #1, txtName.TextClose #1 End Sub
The varibale username if you it isn't painfully obvious just hold the persons name e.g. "Bob", "John" etc
can someone please help?
Text Box / TxT File Sort Code
Can anyone give me the code to put the contents off a text box from highest to lowest (Sort) or sort a text file
Example:
7 - Ash Kri
9 - Kay Wells
8 - Bert Winn
Becomes:
9 - Kay Wells
8 - Bert Winn
7 - Ash Kri
my quiz saves the name from the first form to a text file, so the first line is the name, then from the last form it saves the score so the second line is the score.
Kay Wells
9
Bert Winn
7
So basically i want vb on the last form to organise the contents of an external file in to order of highest first or vb to organise the contents of a text box.
To save to file i use this code:
Code:
Private Sub cmdCal_Click()
Rem Replace 'c: est.txt' with the name of the file you want to edit.
Open "c: est.txt" For Append As #1
Print #1, lblResult.Caption
Close #1
End Sub
And to display the contents i use this:
Code:
Private Sub cmdHighScores_Click()
Rem Change "c: est.txt file to change what contents are displayed in the text box"
Dim iFile As Integer
iFile = FreeFile
Open "C: est.txt" For Input Access Read As #iFile
txtFile.Text = Input(LOF(iFile), #iFile)
Close iFile
End Sub
confused:
Cheers ppl
Need Help On Reading Vb Code From A Text File
ok im looking to find some way to add code into my program that will read the VB code from a text file into the program and use it.
I wanna do this so that i dont have to update the program everytime i add a new thing, this way i can have sections of code into different text files
Save Code To Text File
I wonder it there is a way of saving your code to a text file? This could be using for programs like: Client/Server.
Parsing Code Text File
Hi,
i have some text to parse. The text looks like this
If( X=2)
{
command "arg1",$arg2,arg3,(arg4)
}
I have to create a language and to code all keyword syntax such as The "command" syntax which would allow the user to add as many arg as possible with différent format. Code the fact that "if" is expecting condition and brackets...
Everybody who would give me advice, good site, books, or whatever about parsing would be a star !!!
thanks
Eire21
Bordeaux
France
Source Code In Text File...please Help...
Is it possible to make a text file where i put some source code. Then let vb read the file and execute the source code? I hope you understand what i try to say lol. Then if that work encrypt the text and give it an other extension so that nobody can read that source. Is somthing like a update and external scripts.
Can I Set Landscape In A Text File By VB Code?
In VB6, I am exporting data to a text file like this:
Open cdlSaveAs.FileName For Output As #1
Print #1, myData1
Close #1
ShellExecute vbNull, "open", cdlSaveAs.FileName, vbNull, vbNull, 1
How can I make the file page setup to be landscape?
Executing Vb Code From Text File
please i would like to ask about how to execute A vb code stored in text file
i want to read that file to execute the code sotred there usin vb6
Edited by - ZEEZO on 3/3/2007 12:19:30 AM
Printing To Text File Using Code.
I would like to know the technique of writing in code form VB program to send output to a text file using one / more access tables. Kindly send me a sample code or link where i can find such codes.
Reading VB Code From A Text File
I am trying to figure out how to run VB code from a txt file so that I can change certain parts of my program after I've compiled it by changing a function contained in the text file. Is this possible?
How Do I Create A Text File Using Vb Code?
I have a program that determins whether a text file exists or not and works fine if it does exist.
If the file does not exist, how do I write the vb code to create it?
Thanks in advance...
If Dir("C:abc.txt") = "" then
MsgBox "File with settings does not exist"
else
FileNum = FreeFile
Open "c:abc.txt" for input as #FileNum
for i = 0 to 23
input #FileNum, Reading
Text1(i) = Reading
next
Close #FileNum
End If
Import Text File In Excel Using VB Code
Hi folks,
My problem is that I am trying to automate a system in which a text file is brought into a worksheet. The code I have so far stops at the "Import Text File" window looking for the "Import" or "Cancel" button to be pressed. Even if I click the "Import" button, then the Import Text Wizard comes up and I have to click "Finish". Does anybody know the commands to avoid having to press these buttons and have the file come into the worksheet without user intervention.
The file name is a variable called FileValue. Here is the code:
SendKeys "^{Home}", True
ChDir "O:BakeryOrdRecapTextFiles"
With Selection.QueryTable
.Connection = "TEXT;O:BakeryOrdRecapTextFiles" & FileValue
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 2, 2, 9, 9, 9, 1, 9, 1)
.TextFileFixedColumnWidths = Array(11, 10, 32, 5, 8, 28, 15, 13)
.Refresh BackgroundQuery:=True
End With
Code To Extract Data From Text File
can someone supply me with some code to extract data from a text file from its header to the next blank line which would be the end of the section
plz
How To Read Code From A Text File And Then Apply
Hey,
i've got a assignment which is known as tax calculator. they've asked me to store the rates in different text files and when i click the appropriate radiobuttons (to select year and residency) the program should select the correct rate file and then will calculate the tax and show that in a new textbox (with a label "Your Tax is ="). guys can u plz help me with this...i reallly need help
thanks....
Adding Contents Of Text File To The Code
Hello, I have a text file, which looks like this:
Code:
1=Hello
2=Bye
3=Tomorrow
4=Yesterday
5=Sunday
etc
etc
etc
If my application returns a "3" then it extracts the text file from the application (resource file), reads it and shows the corresponding text (in this case "Tomorrow").
I'd like to get rid of the text file and add the list of text to the code, but I don't know how to do this. Basically I want to check the list internally for the number and show the corresponding text.
Do I need to add the list as one huge string or how would I do this?
Text File Question - Im Using Rhinos Code
VB Code:
Private Sub RemoveLine(sFile As String, sLine As String, sSep As String)Dim sText$, iPos%, iPos2% Open sFile For Input As #1 sText = Input(LOF(1), #1) iPos = InStr(1, sText, sLine) If iPos > 0 Then iPos2 = InStr(iPos + Len(sLine), sText, sSep) If iPos2 > 0 Then sText = Left(sText, iPos - 1) & Mid(sText, iPos2 + Len(sSep)) Else sText = Left(sText, iPos - 1) & Mid(sText, iPos + Len(sLine) + Len(sSep) + 1) End If End If Close #1 Open sFile For Output As #1 Print #1, sText Close #1End Sub 'e..g...RemoveLine "C: est.txt", MarkScore=49485, vbNewLine
But my problem is, lets say the file only has 5 entries, and i remove those 5 entries, the file is empty - fine, this is perfect..
BUT..
when i add a entry abck into the file the entry appears after 5 lines, so there is like a huge space at the top of the text file, any idea why this is happening? (its something to do with line spacing like
or something im not sure)
Help With Text File Search Code - COMPLETED
i am working on a security keypad program that reads from a text file to validate a password, however if the password isn't at the top of the list it doesn't validate. how would i get it to search the entire text file for a password?
Save Text File As Html By Code
I like to copy contents of a text box and paste it on a text file and save it as html file.
The contents should not be taken as a string by string ,it should be copied to the text file as we do manually.
How do i save text file as html file by code...
Pls help me out of this...
Import Text File Into Excel Via VB6 Code
I have a problem that is driving me nuts.
I wish to put a text file into the sheet 2 of an Excel spreadsheet as I have info in sheet 1 which will use sheet2 data. How can this be done. All my code is written in VB6 and do not want to use Excel macros. All I want is to import a text file, surely it is not that difficult I think.
Help
|