?
Solved

Executing a string

Posted on 1998-07-27
14
Medium Priority
?
361 Views
Last Modified: 2011-09-20
Is there a way to execute a string. (In clipper "&" before a variable executed the string as if were a line of code.) Is there a simple way without building an interpreter.
0
Comment
Question by:fred12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +2
14 Comments
 
LVL 2

Expert Comment

by:percosolator
ID: 1466827
No.

What do you wish to accomplish?  

There's almost always another way to do something.

Tell me what you wish to do.


0
 

Author Comment

by:fred12
ID: 1466828
I want to use a database(or list box) to pass data to a variable and have that variable executed like it was a line of code. Ive done this in clipper, foxpro, dbase.
 I know I can parse the string and kinda make my own compiler but it would be limited to the commands I program.
 Is there another way.  
0
 
LVL 2

Expert Comment

by:percosolator
ID: 1466829
could you give me a little more to go on?  VB does not support anything like that.  

I have seen foxpro do it, so I'm with you in that respect.

Could you give a little background, and a simple example?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:fred12
ID: 1466830
example:
variable="form1.enabled = true"
&variable        

this is the same as:
form1.enabled =true

 Of course this &variable does not work in vb. In clipper this was useful because you could use a huge database of commands, it was also very useful for writing/testing code while the exe was executing. Im trying to do the same in vb5. It was a great way to write code, and had lots of other uses.

0
 
LVL 2

Expert Comment

by:percosolator
ID: 1466831
Thought so.

Wanted to do something similar.  Wanted to soft-code an if-then statement, wound-up figuring out how to use SQL Server to evaluate the if-then statement.

You can't do it.  How I would proceed with this is to setup a case statement.

Select Case Comand ' (Deliberate miss-spelling there)

       Case 1:

           Form1.Enabled = True

End Select

or

Select Case Comand

       Case "Enable Form1"

           Form1.Enabled = True

End Select

Or such.

--

           
0
 

Author Comment

by:fred12
ID: 1466832
Thanks
Are you 100% sure. If not I will open question, if no solution is posted in few days re-answer. Unless of course your 100%
possitive.    

0
 
LVL 2

Expert Comment

by:percosolator
ID: 1466833
Yeah.  If it's possible, I'll will be so surprised that I'll drop dead from shock.

I asked two other programmers here. One's used FoxPro, and said, "Yeah, you can do it in FoxPro.  Not VB".  The other doesn't know if you can or not (new guy).

Not sure why you can't.  I've not used FoxPro in a long, long time. (learned on 2.5) It could be that VB's not an interpereter, but a compiler.

But by all means, leave the question open.  Maybe we can get somebody else's input.

I'm 99 & 44/100 % sure. <g>


(old soap ad, or somesuch)

Doug
0
 

Expert Comment

by:frankhommers
ID: 1466834
Try the microsoft scripting control. It'll allow you to execute VBScript or JScript code to an certain extend. (See the microsoft site).
0
 
LVL 39

Expert Comment

by:abel
ID: 1466835
This is something for AI!
Usually a compiled program cannot be modified at runtime. One of the main problems is that when you run your program as an exe, you cannot modify it, because it's locked by the system.
You will have to do your debugging in debugging mode and if you definitely want something like "Execute("Me.Show")" I suggest another solution:

Use C/C++. Make a smart program that looks up all available library-calls to all available libraries. Make it as smart as you want and make additional libraries for statements like "i=i+1". Let the user choose a libraty, a function and the variables. Use the API LoadLibrary and GetProcAddress and call the function.

This is a lot of work, but it can be done. From VB? Forget it, or make your own parser (with a select case statement).

When you succeed, upload it to the Web. There are probably a lot of people waiting for such a tool (maybe I go on making one by myself...). It would be a great testing tool for API's, but it'll be very difficult to simulate VB-statements with it.

One other way: look up the MSVBVM50.DLL and look at the export table. It'll be a lot of work as well, but using these functions you'll be able to emulate a lot of calls. Again, you have to make your parser in C.

I wish you good luck when you go for something like this! You'll need it. If I ever manage to make such a program, I'll try to find you and send it to you. Promised, word of honour!

Regards, Abel

IMPORTANT NOTE:
Try your hands on Perl (www.perl.com it's free and widely documented). You can program anything with it, it runs on compile time (you write a textfile, perl parses it and compiles it and then runs it) and you can modify code on the fly. You can even execute perl-statements with another perl-statement! Might be the programming language you need for this, but unfortunately it's mainly made for writing to stdout (meaning that it's a very useful program for use with Web-page creation). Luckily there are lots of additionals out there with which you can write full functional GUI code. Almost all of them are free to get as well.
0
 

Author Comment

by:fred12
ID: 1466836
Well percosolator, Im glad your not going to drop dead. Answer question in few days if no new comments appear, thanks again.

 Thanks for the comment frankhommers, its half of what I need.

 abel. Im afraid this is too much of tackle for me, However Im going to try pearl. If ever you do this in C I would appreciate  a copy My email is hbdevice@netcom.ca  
 Your comment were insightfull thanks alot.

0
 
LVL 2

Expert Comment

by:polygon
ID: 1466837
you may never get what you with VB. just forget about your it or make your own compiler?!?
0
 
LVL 2

Accepted Solution

by:
percosolator earned 200 total points
ID: 1466838
Well, fred12.  I would have really like to have been shown that it can be done; every now and then it would be useful.

You implementing the case statement approach?

0
 
LVL 39

Expert Comment

by:abel
ID: 1466839
I will keep your email and let you know whenever I decide to make such a program and when it's finished.

Regards, Abel

PS1: The Perl function I was talking about is "eval".
PS2: It really is Perl, not Pearl.
0
 

Author Comment

by:fred12
ID: 1466840
Thanks to all for your time and coments

No case statement I'm taking up "perl"
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question