-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_cui.rb
93 lines (80 loc) · 2.51 KB
/
core_cui.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#! ruby -Ks
# -*- mode:ruby; coding:shift_jis -*-
$KCODE='s'
lib = <<EOS
#! ruby -Ks
# -*- mode:ruby; coding:shift_jis -*-
$KCODE='s'
#Set 'EXE_DIR' directly at runtime 直接実行時にEXE_DIRを設定する
EXE_DIR = (File.dirname(File.expand_path($0)).sub(/\\/$/,'') + '/').gsub(/\\//,'\\\\') unless defined?(EXE_DIR)
#Available Libraries 使用可能ライブラリ
#require 'jcode'
#require 'nkf'
#require 'csv'
#require 'fileutils'
#require 'pp'
#require 'date'
#require 'time'
#require 'base64'
#require 'win32ole'
#require 'Win32API'
#require 'vr/vruby'
#require 'vr/vrcontrol'
#require 'vr/vrcomctl'
#require 'vr/clipboard'
#require 'vr/vrddrop.rb'
#require 'json'
#require 'sqlite3'
#Predefined Constants 設定済み定数
#EXE_DIR ****** Folder with EXE files[It ends with '\\'] EXEファイルのあるディレクトリ[末尾は\\]
#MAIN_RB ****** Main ruby script file name メインのrubyスクリプトファイル名
#ERR_LOG ****** Error log file name エラーログファイル名
#The condition is positive when this split is executed directly.
#このスプリクトを直接実行時に条件が正になる。
if (defined?(ExerbRuntime) ? EXE_DIR + MAIN_RB : $0) == __FILE__
print "Program execution ended. Press the Enter key."
STDIN.gets
end
EOS
EXE_DIR = File.dirname(ExerbRuntime.filepath) + '\\'
MAIN_RB = File.basename(ExerbRuntime.filepath,'.*') + '.rb'
ERR_LOG = File.basename(ExerbRuntime.filepath,'.*') + '_err.txt'
core_ruby = EXE_DIR + MAIN_RB
err_log_file = EXE_DIR + ERR_LOG
$LOAD_PATH.push(EXE_DIR.gsub(/\\/,'/').sub(/\/$/,'')) if $Exerb
if File.exist?(core_ruby)
if File.exist?(err_log_file)
File.delete(err_log_file)
end
begin
require core_ruby if $Exerb
rescue Exception => e
unless e.message == 'exit'
errmsg = "******** Terminated with error ********\n\n"
errmsg += "******** Error message ********\n" + e.inspect + "\r\n******** Backtrace ********\r\n"
e.backtrace.each{|a| errmsg += a + "\n"}
puts errmsg
begin
File.open(err_log_file,'w') do |f|
errmsg.each do |a|
f.puts a
end
end
puts "\nError log file = #{err_log_file}"
rescue
puts "\nThe error log file could not be created (not writable)."
end
print "Press the Enter key."
STDIN.gets
end
end
else
puts "There is no '#{core_ruby}', I will create it."
File.open(core_ruby,'w') do |f|
lib.each do |a|
f.puts a
end
end
print "Press the Enter key."
STDIN.gets
end