|
Prev: error 5 on unload form
Next: downloading files
From: Roger on 1 Apr 2008 15:25 Hi Everyone, I need to input a command line from an external file, and run it in my Visual Basic program. Any ideas on how to do this? I can Open the file and get the command copied into a "String" variable. But how do I run this variable as a command line? For example the external file has a line with: Print "Hi" How could I take that line in and run it, in real time? This is very simplistic of what I eventually need to do with this program. Thanks Roger
From: Bob Butler on 1 Apr 2008 15:33 "Roger" <Roger.Zimmerman(a)gmail.com> wrote in message news:a5db84da-00da-4722-a5ba-0c91a8f15d7a(a)s8g2000prg.googlegroups.com... > Hi Everyone, > > I need to input a command line from an external file, and run it in my > Visual Basic program. > > Any ideas on how to do this? > > I can Open the file and get the command copied into a "String" > variable. > > But how do I run this variable as a command line? > > For example the external file has a line with: Print "Hi" > > How could I take that line in and run it, in real time? > > This is very simplistic of what I eventually need to do with this > program. What version of VB? With VB 6 or earlier the scripting control might be an option. Other options may also exist but would depend on how complex the statements can be.
From: Auric__ on 1 Apr 2008 16:14 On Tue, 01 Apr 2008 19:25:35 GMT, Roger wrote: > Hi Everyone, > > I need to input a command line from an external file, and run it in my > Visual Basic program. > > Any ideas on how to do this? > > I can Open the file and get the command copied into a "String" > variable. > > But how do I run this variable as a command line? > > For example the external file has a line with: Print "Hi" > > How could I take that line in and run it, in real time? > > This is very simplistic of what I eventually need to do with this > program. You need an interpreter. You can either use an external interpreter, such as the scripting control mentioned by Mr. Butler, or write your own. (Option 2 generally isn't worth the effort, especially when you consider that there are dozens of interpreters available for many many languages.) -- Thanks for the nightmares.
From: Roger on 1 Apr 2008 17:24 Welllll, actually I am using Gambas, but can't find a very good support site on it. It is very close to VB6. I looked up scripting and found an EXEC function, but it only ran commands that run in the Console (i.e. not Basic code). Is there another way to do scripting from within BASIC that runs BASIC code? Thanks Roger
From: Auric__ on 1 Apr 2008 17:52
On Tue, 01 Apr 2008 21:24:55 GMT, Roger wrote: > Welllll, actually I am using Gambas, but can't find a very good > support site on it. > It is very close to VB6. > I looked up scripting and found an EXEC function, but it only ran > commands that run in the Console (i.e. not Basic code). > Is there another way to do scripting from within BASIC that runs BASIC > code? AFAIK, there is no "standard" method for interpreting BASIC code from a string. I suggest looking through the docs -- I only played with Gambas once and didn't like it. You probably need an interpreter. If it's under Windows, then use Windows scripting. (I'm pretty sure that Gambas can call Windows DLLs.) If it's under *nix, you can pass the code to the appropriate interpreter (which is usually specified in the first line: "#!/bin/sh" or "#!/usr/bin/perl" or whatever) or just do something like this: exec "/usr/bin/perl", "~/myscript" -- I bow before your prowess. |