Update: This post is outdated. All in one installer for 1.9
is ready now, you should use it if you need 1.9 on windows. Get it here
http://rubyforge.org/frs/?group_id=167
Ruby has “all-in-one” installer for Windows, but it is outdated. As
of May 2009, Ruby 1.9.1 is released, the installer is still 1.8.6. If
you want the latest version, you need the zip package. But the zip
package is missing zlib.dll, libeay32.dll, ssleay32.dll and readline.dll
. Here is how to install it on windows.
Download the file
First you download the 1.9 package from http://www.ruby-lang.org/en/downloads/
Choose “Ruby 1.9 xxx binary” instead of “Ruby xxx Installer”.
Install it
Just Unpack the zip to c:\ruby.
Then add c:\ruby\bin to windows PATH.
Open a windows command console and type
gem update --system
Oops, it is broken! The binary is missing some dll files.
Let us fix it
zlib
Download zlib windows binary from
http://gnuwin32.sourceforge.net/ ......
Ruby语言学习系列--基本的ruby语法
1. 基本的ruby语法
1.1 变量、常量和类型
1) 定义变量
变量类型
描述
示例
局部变量(或伪变量)
以小写字母或下划线卡头
var _var
全局变量
以$开头
$var
类变量
类中定义,以@@开头
@@var
实例变量
对象中定义,以@开头
@var
常量
以大写字母开头
Var
2) 变量内插
在双引号内使用“#{变量名}”内插变量
a = 2
b = 3
puts "#{a} + #{b} = #{a+b}" #输入结果为:2 + 3 = 5
1.2 注释
1)单行注释:以#开头,如: #注释内容
2)多行注释:在=begin 和 =end 之间定义,如:
=begin
注释内容
=end
1.3 循环和分支
1.3.1 条件语句
If 形式
unless 形式
a =1 if y==3
a=1 unless y!=3
x= if a > 0 then b else c end
x= unless a<=0 then a else b end
if x<5 then
a =1
else
a =2
end
unles ......
项目中用到了此功能。把大概做法跟大家共享下,希望对大家有所帮助。也给自己总结一下,激励自己再接再厉。下面中部分代码被汉字替换了,主要考虑到公司的产品权,希望谅解。
/// <summary>
/// 点击打开按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOpen_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog ofd = new OpenFileDialog();
......
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using Microsoft.Win32;
using Access = Microsoft.Office.Interop.Access;
namespace ImageAccess
{
static class Program
{
#region DllImportAttribute
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
static extern bool ShowWindow(IntPtr handle, int flags);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
static extern bool SetForegroundWindow(IntPtr handle);
#endregion
[STAThread]
static void Main()
{
......
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using Microsoft.Win32;
using Access = Microsoft.Office.Interop.Access;
namespace ImageAccess
{
static class Program
{
#region DllImportAttribute
[DllImport("user32.dll", EntryPoint = "ShowWindow")]
static extern bool ShowWindow(IntPtr handle, int flags);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
static extern bool SetForegroundWindow(IntPtr handle);
#endregion
[STAThread]
static void Main()
{
......
在SQL Server中模糊查询通常是这样的Select * from articleTable where authorName like '%jacky%'
但是在Access中用这条语句执行的时候竟然发现查不出结果,怎么可能呢?
后来查了下资料,发现问题如下:
要进行模糊查找,则必须使用通配符,ACCESS库的通配符和SQL SERVER的通配符不一样。
ACCESS库的通配符为:
* 与任何个数的字符匹配。
? 与任何单个字母的字符匹配
在SQL Server中的通配符为:
% 与任何个数的字符匹配
- 与单个字符匹配
但是又发现,C#连接到Access数据库之后,用这样一条语句Select * from articleTable where authorName like '*jacky*' (注意,这边按照上述通配符的要求将%修改为*了)竟然搜索不到应该存在的N条记录,我靠 ......