从VB脚本访问和更改VB.net中定义的变量? [英] Access and change variables defined in VB.net from a VB Script?

查看:135
本文介绍了从VB脚本访问和更改VB.net中定义的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已经在VB.net中编写了一段时间的应用程序-它可以创建动画.我想允许用户通过编写脚本来创建自己的效果,滤镜和其他过程,这些脚本将访问和更改正在运行的程序中的变量.我不想创建自己的脚本解释器,而是希望使用VBScript.

这可能吗,如果可以的话,最好的方法是什么?我一直在看COM iterop,但是到目前为止,我读到的所有内容都困扰我.

I have an application that I have been writing in VB.net for a while now - it creates animation. I want to allow users to create there own effects, filters, and other processes by writing scripts that will access and change the variables in the running program. I do not want to create my own script intepreter and would rather use VBScript.

Is this possible and if so what is the best method. I have been looking at COM iterop, but so far everything I have read has been over my head.

推荐答案

有两种方法可以解决此问题.

一种方法是使用可视界面.向用户显示一组单选按钮,复选框和/或下拉菜单.当按下执行"按钮时,您可以解析选择内容以应用过滤器等.您可以对选项进行编码,以将选择内容序列化为XML文件,从而允许用户保存设置.当用户重新加载文件时,它将设置接口的值.然后,用户可以进行进一步的调整或简单地运行它.

此方法的优点是,您可以在应用程序的更高版本中更改界面,同时保持与旧XML文件的向后兼容性.由于仍然需要构建错误检查和验证,因此可以允许高级用户直接修改文件.

执行此操作的另一种方法是创建自定义脚本语言.它不需要非常复杂,只需坚持使用简单的谓词语法,例如APPLY FILTER BLUR(20)或FADE RGB(0,0,0).也许我才刚老,但是在过去,我们曾经写过使用这种结构的基于文本的计算机游戏,这很容易.

我认为VBScript不太适合您想要的:您想为您的用户提供一套简单,小巧且相当直观的工具.
There are a couple of ways to approach this.

One way would be to use a visual interface. Present the user with a set of radio buttons, checkboxes and/or drop-downs. When the "Do it" button is pressed, you can then parse the selections to apply filters etc. You can code an option to serialize the selections into an XML file, which allows the user to save settings. When the user reloads the file, it would set the values of the interface; the user can then make further tweaks or simply run it.

The advantage to this method is that you can change the interface in latter versions of your app while remaining backwards compatable to older XML files. Because you would need to build error-checking and validation anyway, you can allow advanced users to modify the files directly.

Another way to do this would be to create a custom scripting language. It doesn''t need to be terribly complex, just stick to a simple verb-predicate syntax like APPLY FILTER BLUR(20) or FADE RGB(0,0,0). Maybe I''m just old, but back in the day we used to write text-based computer games that used that kind of structure, it''s pretty easy.

I don''t think VBScript would be well suited to what you want: you want to give your users an easy, small and reasonably intuitive set of tools.


这篇关于从VB脚本访问和更改VB.net中定义的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆