[翻译]kean' blog f#的第一个autocad程序 - 精华帖集合
www.dimcax.com
[翻译]kean' blog f#的第一个autocad程序
哈喽大家好,上周比较忙,今天继续为大家献上kean的文章。 浏览kean的blog,发现最近两个月他对f#关注挺多的,他第一篇关于f#的文章题目为《f#-a perfect fit for autocad .net programming?》,貌似他对f#希望很高,并且以后的关注重点也会放在f#。因此,我会陆续把这一系列关于f#的文章都翻译来。 ok,废话不说,开始第一个。 ============================================ 下面是第一个(非常简单的)工作于autocad下的f#程序的步骤。 首先我们需要从下载最新的f# research(现在是1.9.2.9), 我们创建一个基本的f#工程,选择"f# project"模板: 接下来我们给这个工程添加一个"f# source file": 这个文件包含了许多模板代码,通过这些代码我们可以对f#语言有一个大致的了解。 下来我们继续,我们把这些替换成我们自己编写的代码: (* use lightweight f# syntax *) #light (* declare a specific namespace and module name *) module mynamespace.myapplication (* import managed assemblies *) open system open system.windows.forms open autodesk.autocad.runtime (* now we declare our command *) ["test")>] let f () = (* create our form *) let frm = new form() frm.text <- "this is a winform" frm.height <- 80 frm.width <- 360 frm.startposition <- formstartposition.centerscreen (* create the contents: a label a textbox a button *) let lb = new label() lb.text <- "enter text: " lb.width <- 60 lb.left <- 10 lb.top <- 12 let tb = new textbox() tb.left <- 80 tb.top <- 10 tb.width <- 200 (* define an eventhandler for the click event and attach it to the button *) let mb _ _ = ignore( messagebox.show( tb.text, "text typed:" ) ) let eh = new eventhandler(mb) let bt = new button() bt.text <- "submit" bt.left <- 290 bt.top <- 8 bt.width <- 50 bt.click.addhandler(eh) (* add the controls to our form *) frm.controls.add(lb) frm.controls.add(tb) frm.controls.add(bt) (* display the form *) application.run(frm) 为了使代码通过编译,我们必须在工程设置中添加引用,,并且把类型设置为"dll": 编译以后,生成"myfirstfsharp.dll"。我们用netload命令在autocad中加载,然后键入test命令: 当我们键入一些文字然后单击"submit“,一个显示我们输入的文字的对话框弹出: ================================================ 又要忙了,今天先到这儿。
f#是什么东东?
f#是微软一个正在研发中的编程语言,是一种函数式语言,关于f#的详细介绍请baidu或google.
c#最适合开发autocad,因为它拥有vb容易的特点,却具有vc++的强大功能。
kean的blog这几天一直上不去,本来还说继续翻译f#的其他文章了。。。。汗一个
原帖由 cloudlove 于 2008-1-24 02:09 pm 发表 kean的blog这几天一直上不去,本来还说继续翻译f#的其他文章了。。。。汗一个
可惜了,都不知道跑哪去了
原帖由 admin 于 2008-1-22 07:11 pm 发表 f#是微软一个正在研发中的编程语言,是一种函数式语言,关于f#的详细介绍请baidu或google.
用google搜索"f#" 约有7,120,000项符合 但用百度搜索"f#" 抱歉,没有找到与"f#"相关的网页。
同感哦,百度现在还是搜不到