wp-syntaxhighlighterの記事は野性の証明でないと見られません
野性の証明 を参照。
wp-syntaxhighlighter を参照。
アイキャッチ画像は最近のカスケードメニューです。
ソフトウェア関連の記事
野性の証明 を参照。
wp-syntaxhighlighter を参照。
アイキャッチ画像は最近のカスケードメニューです。
– WSL上で実施
– PyCharm上で実施
Flask – static -css – stylexx.css - xxx.css ・ ・ -images – xxxx.jpg - xx.gif ・ ・ -js – xxxxxxx.js - yyy.js ・ ・ - templates – xxxxxx.html - index.html ・ ・ ・ ・ -demo01.py -demoxx.py ・ ・ ・ ・ indexShift_JIS.html indexUTF-8.html ・ ・ (例) ~$ cd flask emacs demoxx.py python3 demoxx.py ~$ nkf -w < format01S_JIS.py > format01UTF-8.py ~$ sudo mount -t drvfs f: /mnt/usb/ ~$ cp -r flask /mnt/usb/
Syntax Highlitでプログラムを再掲する。
Syntax Highlitでプログラムを再掲する。
Sub チェック() Dim i As Long 'カウンタ変数 ※→「開発」→「マクロ」→「Module1」→「ツール」→「マクロ」→「チェック」→「編集」 Dim myTemporary As Long 'あまりの処理 Dim myAmari As Long Dim myGANS As Long 'Counter Good Answer Dim SRT_BS As Long 'Displacement Count Area Dim ST_PTR As Long '生徒のラインナンバー Dim myANSWR As Boolean '割り算の商と余りが両方あってなければいけない ' Code myGANS = 0 'Initialize myANSWR = False Sheets("Sheet1").Select 'Select Sheet1 myOperator = Cells(1, 10).Value For i = ORG_CLM To DST_CLM 'A列の値とC列の値の和がE列に入力された答えと正しいか判定 If myOperator = "+" Then SRT_BS = 5 If Cells(i, NUM1_RW).Value + Cells(i, NUM2_RW).Value = Cells(i, ANSW_RW).Value Then Cells(i, ANSW_RW).Font.Color = vbBlue '正解なら文字色を青に myGANS = myGANS + 1 Else Cells(i, ANSW_RW).Font.Color = vbRed '不正解なら文字色を赤に End If End If If myOperator = "-" Then SRT_BS = 10 If Cells(i, NUM1_RW).Value - Cells(i, NUM2_RW).Value = Cells(i, ANSW_RW).Value Then Cells(i, ANSW_RW).Font.Color = vbBlue '正解なら文字色を青に myGANS = myGANS + 1 Else Cells(i, ANSW_RW).Font.Color = vbRed '不正解なら文字色を赤に End If End If If myOperator = "*" Then SRT_BS = 15 If Cells(i, NUM1_RW).Value * Cells(i, NUM2_RW).Value = Cells(i, ANSW_RW).Value Then Cells(i, ANSW_RW).Font.Color = vbBlue '正解なら文字色を青に myGANS = myGANS + 1 Else Cells(i, ANSW_RW).Font.Color = vbRed '不正解なら文字色を赤に End If End If If myOperator = "/" Then SRT_BS = 20 If Int(Cells(i, NUM1_RW).Value / Cells(i, NUM2_RW).Value) = Cells(i, ANSW_RW).Value Then Cells(i, ANSW_RW).Font.Color = vbBlue '正解なら文字色を青に myANSWR = True Else Cells(i, ANSW_RW).Font.Color = vbRed '不正解なら文字色を赤に End If myTemporary = Int(Cells(i, NUM1_RW).Value / Cells(i, NUM2_RW).Value) myAmari = Cells(i, NUM1_RW).Value - myTemporary * Cells(i, NUM2_RW).Value If Cells(i, AMAR_RW).Value = myAmari Then Cells(i, AMAR_RW).Font.Color = vbBlue If myANSWR = True Then myGANS = myGANS + 1 End If Else Cells(i, AMAR_RW).Font.Color = vbRed End If End If Next i If myGANS = SEIKAI_SU Then MsgBox "全問正解です。おめでとう!" Else MsgBox "もうちょっと!" End If SRT_RW = Cells(1, 13).Value 'Bias Locate depend on 横 operator Sheets("Sheet2").Select SRT_BS = SRT_BS + SRT_RW 'Fix Count Location ST_PTR = Cells(1, 14).Value 'Current 生徒の行 Cells(1, 15).Value = SRT_BS '横のLocation Cells(ST_PTR, SRT_BS) = myGANS '正解数を入れる Sheets("Sheet1").Select 'Change Manage Page To Question Page End Sub Sub リセット() Dim i As Long 'カウンタ変数 Dim myTemporary As Long UserForm3.Show 'Show List2 Sheets("Sheet2").Select 'Select Sheet2 If IsNumeric(Cells(1, 11).Value) Then ' MsgBox "True" If Cells(1, 11).Value = 0 Then ST_NUM = 4 Cells(1, 11).Value = ST_NUM Else ST_NUM = Cells(1, 11).Value '前回からの登録簿のスタート値を使用 'MsgBox ST_NUM End If Else ST_NUM = 4 '生徒ライン番号初期化 Cells(1, 11).Value = ST_NUM '生徒ライン番号初期化 MsgBox ST_NUM 'for debug End If If MsgBox("追加登録しますか?", vbYesNo) = vbYes Then '追加登録をするか? Do While Cells(1, 12).Value <> "End" '後でENDをセットするルーチンを作る事 If Cells(1, 12).Value = "End" Then '登録作業エンド Sheets("Sheet2").Select 'Select Sheet2 End If Cells(1, 10).Value = "Error" 'Error Flag On? Do While Cells(1, 10).Value = "Error" FRM_USER.Show 'User Form Show Registry ID Loop Cells(1, 10).ClearContents 'Error Flag On? Loop 'New Loop End Else MsgBox "今回は登録しません。" Sheets("Sheet2").Select Cells(1, 12).Value = "End" End If '問題出題 Sheets("Sheet2").Select 'Servey Loop End If Cells(1, 12).Value = "End" Then Cells(1, 12).ClearContents 'For debug Sheets("Sheet1").Select 'Select Sheet1 UserForm1.Show 'UserForm1 Show 加減乗除 UserForm2.Show '桁数セット End If Sheets("Sheet1").Select 'Select Sheet1 myBias = Cells(1, 11).Value 'WorkCell for Bias Value myOperator = Cells(1, 10).Value 'Workarea for Operator For i = ORG_CLM To DST_CLM Cells(i, ANSW_RW).ClearContents '値をクリア Cells(i, AMAR_RW).ClearContents Cells(i, ANSW_RW).Font.Color = vbBlack '文字色を黒に Cells(i, AMAR_RW).Font.Color = vbBlack Cells(i, NUM1_RW).Value = Int(Rnd * myBias) 'A列に1桁~4桁のランダムな数値を入力 Cells(i, OPR_RW).Value = myOperator '四則演算子を入れる Cells(i, NUM2_RW).Value = Int(Rnd * myBias) 'A列に1桁~4桁のランダムな数値を入力 If myOperator = "-" Then myTemporary = Cells(i, NUM1_RW) If Cells(i, NUM1_RW) < Cells(i, NUM2_RW) Then Cells(i, NUM1_RW) = Cells(i, NUM2_RW) Cells(i, NUM2_RW) = myTemporary End If End If If myOperator = "/" Then myTemporary = Cells(i, NUM1_RW) If Cells(i, NUM1_RW) < Cells(i, NUM2_RW) Then Cells(i, NUM1_RW) = Cells(i, NUM2_RW) Cells(i, NUM2_RW) = myTemporary If Cells(i, NUM2_RW) = 0 Then 'Escape 0 devide Cells(i, NUM2_RW) = 1 End If Else If Cells(i, NUM2_RW) = 0 Then 'Escape 0 devide Cells(i, NUM2_RW) = 1 End If End If End If Next i End Sub Option Explicit Dim strMSG As String Public ST_NUM As Long Private Sub TextBox2_Change() MsgBox "Box2" Unload Me End Sub Private Sub TextBox3_Change() MsgBox "Box3" Unload Me End Sub Private Sub FRM_USER() MsgBox "FRM_USER()" Unload Me End Sub Private Sub CMD_OK_Click() 'UserForm_Click() 'MsgBox "Execute _Click() on Registry" Sheets("Sheet2").Select 'Select Sheet2 If OptionButton1.Value = True Then '登録終了 Cells(1, 12).Value = "End" End If If OptionButton2.Value = True Then Cells(1, 12).ClearContents End If If OptionButton3.Value = True Then Cells(1, 13).Value = "指定" 'Fix Row End If '入力内容のチェック If Trim$(TXT_NAME.Text) = "" Then strMSG = "氏名が入力されていません。" ElseIf Trim$(TXT_CODE.Text) = "" Then strMSG = "生徒Noが入力されていません。" ElseIf Trim$(TXT_SCLNM.Text) = "" Then strMSG = "学校名が入力されていません。" ElseIf IsNumeric(Trim$(TXT_CODE.Text)) <> True Then strMSG = "生徒Noが数字ではありません。" ElseIf Len(Trim$(TXT_CODE.Text)) <> 5 Then strMSG = "生徒Noは5桁で入力してください。" ElseIf Trim$(TXT_CODE.Text) < 10000 Then strMSG = "生徒Noは10000以上で入力してください。" End If Sheets("Sheet2").Select 'Select Sheet2 If Trim$(strMSG) <> "" Then Cells(1, 10).Value = "Error" 'Set Error Flag MsgBox strMSG Else Cells(1, 10).ClearContents 'Clear Error Flag ST_NUM = Cells(1, 11).Value '生徒の番号をセット Cells(ST_NUM, 1).Value = Trim$(TXT_NAME.Text) '氏名 Cells(ST_NUM, 2).Value = Trim$(TXT_CODE.Text) '生徒No Cells(ST_NUM, 3).Value = Trim$(TXT_SCLNM.Text) '学校名 ST_NUM = ST_NUM + 1 'Sheet2の行No Cells(1, 11).Value = ST_NUM 'Save 生徒No End If Unload Me End Sub Option Explicit Private Sub CommandButton1_Click() ListBox1.RowSource = "Sheet2!A4:A103" 'Set List 'Unload Me End Sub Private Sub ListBox1_Click() 'MsgBox Cells(ListBox1.ListIndex + 1, 1) 'Display ST_NUM 生徒No 'MsgBox ListBox1.ListIndex 'Line No. ST_PTR - 4 Sheets("Sheet2").Select Cells(1, 14).Value = ListBox1.ListIndex + 4 'MsgBox ListBox1.ListIndex + 4 'Line NO. ST_PTR End Sub Option Explicit Dim strMSG As String Public ST_NUM As Long Private Sub TextBox2_Change() MsgBox "Box2" Unload Me End Sub Private Sub TextBox3_Change() MsgBox "Box3" Unload Me End Sub Private Sub FRM_USER() MsgBox "FRM_USER()" Unload Me End Sub Private Sub CMD_OK_Click() 'UserForm_Click() 'MsgBox "Execute _Click() on Registry" Sheets("Sheet2").Select 'Select Sheet2 If OptionButton1.Value = True Then '登録終了 Cells(1, 12).Value = "End" End If If OptionButton2.Value = True Then Cells(1, 12).ClearContents End If If OptionButton3.Value = True Then Cells(1, 13).Value = "指定" 'Fix Row End If '入力内容のチェック If Trim$(TXT_NAME.Text) = "" Then strMSG = "氏名が入力されていません。" ElseIf Trim$(TXT_CODE.Text) = "" Then strMSG = "生徒Noが入力されていません。" ElseIf Trim$(TXT_SCLNM.Text) = "" Then strMSG = "学校名が入力されていません。" ElseIf IsNumeric(Trim$(TXT_CODE.Text)) <> True Then strMSG = "生徒Noが数字ではありません。" ElseIf Len(Trim$(TXT_CODE.Text)) <> 5 Then strMSG = "生徒Noは5桁で入力してください。" ElseIf Trim$(TXT_CODE.Text) < 10000 Then strMSG = "生徒Noは10000以上で入力してください。" End If Sheets("Sheet2").Select 'Select Sheet2 If Trim$(strMSG) <> "" Then Cells(1, 10).Value = "Error" 'Set Error Flag MsgBox strMSG Else Cells(1, 10).ClearContents 'Clear Error Flag ST_NUM = Cells(1, 11).Value '生徒の番号をセット Cells(ST_NUM, 1).Value = Trim$(TXT_NAME.Text) '氏名 Cells(ST_NUM, 2).Value = Trim$(TXT_CODE.Text) '生徒No Cells(ST_NUM, 3).Value = Trim$(TXT_SCLNM.Text) '学校名 ST_NUM = ST_NUM + 1 'Sheet2の行No Cells(1, 11).Value = ST_NUM 'Save 生徒No End If Unload Me End Sub Option Explicit Public myOperator As String Const OPR_RW As Integer = 2 Private Sub CommandButton1_Click() 'UserForm_Click() Sheets("Sheet1").Select 'Select Sheet1 If OptionButton1.Value = True Then myOperator = "+" End If If OptionButton2.Value = True Then myOperator = "-" End If If OptionButton3.Value = True Then myOperator = "*" End If If OptionButton4.Value = True Then myOperator = "/" End If 'MsgBox myOperator Cells(1, 10).Value = myOperator 'Save Operator as String Unload Me End Sub 'Private Sub UserForm_Click() ' 'UserForm.Show ' MsgBox "Before CommandButton1" 'End Sub Private Sub UserForm_Click() End Sub Option Explicit Public myBias As Long Public SRT_RW As Long Private Sub CommandButton1_Click() 'UserForm_Click() Sheets("Sheet1").Select 'Select Sheet1 SRT_RW = 0 'Initialize Operator Bias Location 'MsgBox "Before CommandButton1" If OptionButton1.Value = True Then '1桁 myBias = 10 SRT_RW = SRT_RW + 0 End If If OptionButton2.Value = True Then '2桁 myBias = 100 SRT_RW = SRT_RW + 1 End If If OptionButton3.Value = True Then '3桁 myBias = 1000 SRT_RW = SRT_RW + 2 End If If OptionButton4.Value = True Then '4桁 myBias = 10000 SRT_RW = SRT_RW + 3 End If 'MsgBox myBias Cells(1, 11).Value = myBias 'Save 桁数 Cells(1, 13).Value = SRT_RW Unload Me End Sub 'Private Sub UserForm_Click() ' MsgBox "Here is UserForm2" 'UserForm2.Show 'End Sub Private Sub UserForm_Click() End Sub Option Explicit Private Sub CommandButton1_Click() ListBox1.RowSource = "Sheet2!A4:A103" 'Set List 'Unload Me End Sub Private Sub ListBox1_Click() 'MsgBox Cells(ListBox1.ListIndex + 1, 1) 'Display ST_NUM 生徒No 'MsgBox ListBox1.ListIndex 'Line No. ST_PTR - 4 Sheets("Sheet2").Select Cells(1, 14).Value = ListBox1.ListIndex + 4 'MsgBox ListBox1.ListIndex + 4 'Line NO. ST_PTR End Sub
– 他の「demoxx.html」プログラムは省略します。
– 後日機会があったら当ブログに載せます。
#!/usr/bin/python3 # -*- coding: utf-8 -*- #demo32.py sessin managed & username get from flask import Flask, redirect, request, render_template, url_for, session app = Flask(__name__) @app.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'POST': session['username'] = request.form['username'] return redirect(url_for('index')) return render_template('demo07.html') @app.route('/program', methods=['GET', 'POST']) def program(): if request.method == 'POST': session['username'] = request.form['username'] return redirect(url_for('index')) return render_template('demo03.html') @app.route('/program1', methods=['GET', 'POST']) def program1(): if request.method == 'POST': session['username'] = request.form['username'] return redirect(url_for('index')) return render_template('demo04.html') @app.route('/program2', methods=['GET', 'POST']) def program2(): if request.method == 'POST': session['username'] = request.form['username'] return redirect(url_for('index')) return render_template('demo05.html') @app.route('/param/<parameter>') def show_user_profile(parameter): if 'username' in session: html = render_template('demo07.html',name = str(parameter)) return html return 'You are not logged in. from param processing' @app.route('/reset', methods=['GET', 'POST']) def reset(): session['username'] = 'monkey' return render_template('check31.html') @app.route('/') def func(): if 'username' in session: html = render_template('demo07.html',name = str(session['username'])) return html return 'You are not logged in' @app.route('/check', methods=['GET', 'POST']) def check(): if request.method == 'POST': session['username'] = request.form['username'] return redirect(url_for('func')) return render_template('check31.html') @app.route('/',methods=['POST']) def index(): if (request.form['attr'] == 'need'): success = False name = request.form["username"] passwd = request.form["pass"] att1 = request.form['attr'] my_message = "keyword処理は?" else: con1 = request.arg.get('_ControlID') pg1 = int(request.arg.get('_PageID')) act1 = request.arg.get('_ActionID') flg1 = request.arg.get('getFlg') html = render_template('demo07.html', con = con1, pg = str(pg1), act = act1, flg = flg1) return html user_data = [{"id":"カリフラワー", "pass":"hanakyabetsu"},{"id":"西行法師", "pass":"masako"},{"id":"monkey", "pass":"kayochan"},{"id":"program1", "pass":"pass1"}] for i in range(0, 10): if user_data[i]["id"] == name: if user_data[i]["pass"] == passwd: success = True session['username'] = name return render_template('demo07.html',suc=success,name=name,pas=passwd,msg=my_message,att=att1) else: continue else: continue success = False return render_template('demo07.html',suc=success,name=name,pas=passwd,msg=my_message,att=att1) @app.route('/logout') def logout(): session.pop('username', None) return redirect(url_for('func')) app.secret_key = 'B0Qp89i/2xY F~XHH!jnVVLWX/,%QR' if __name__ == '__main__': app.run(debug=True)
– 以上セッション処理プログラムでした。
次のような理由でコースを途中でQuitした。
まだ、様々な基本知識の欠落がある。
オブジェクト指向言語を学習中。
5ヶ年計画で目標はAIのリテラシーが分かればよい。
でもコースのカリキュラムが知りたい。
そこでこのコースの章立てを紹介する。
Coursera machine Learning(スタンフォード大学)
講師:Andrew Ng
******************************************************
Introduction
Test
Linear Regression with One Variable
Test
Linear Algebra Review
Test
Linear Regression with Multiple Variables
Test
Octave/Matlab Tutorial
Test
Programming
Logistic Regression
Test
Regularization
Test
Neural Networks:Representation
Test
Programming
Multi-Class Classification and Neural Networks
Test
Programming
Advice for Applying machine Learning
Test
Programming
Regularized Linear Regression and Bias/Variance
Test
Support Vector Machines
test
Programming
Unsupervised Learning
Test
Dimensionality Reduction
Test
Programming K-means Clustering and PCA
Anomaly Detection
Test
Recommender Systems
Test
Programming
Large Scale Machine Learning
Test
Application Example:Photo OCR
Test
**************************************************
Testは80%以上で次に進める。
ProgrammingはOctave。
基本、数学は80%以上で先に進めたがそれ以降は途中でQuitした。(実力不足)
これで5年かけて徐々に計画を進めるとの方針が再び決まった。
話は変わりますが、クラウドを勉強するうえでQiitaで有用な記事を見つけたので将来ブログにアップしたいと思っています。
CNCFとは
CNCFは2015年7月に発表され、約50社が集まり2016年1月に正式発足した。最初の発表から4年後2019年11月のメンバーは約500団体で、大手クラウド事業者、ミドルウェア企業、ハードウェア製造企業、オープンソース・ソフトウェア企業、大学、その他非営利団体などが加入している。
WordPressでSyntaxHighlightができるようになった。
Python ProgramのClassの例である。
これでテキストをコピペできるようになったが、その代わりHydrogenの結果などを表現できなくなった。長短相半ばするといったところか。今後は場合によって両者を使い分けることとする。
class Fish: def __init__(self, name, build="ほね", eyelids=False): self.name = name self.build = build self.eyelids = eyelids def swim(self): print("こちらの魚は泳ぎます") def swim_back(self): print("こちらの魚は後ろ向きにも泳ぎます") class Medaka(Fish): pass #mach1 mach = 1225 topspeed = 40000 print(topspeed / mach) no0 = Fish("魚1号(親クラス)") print(no0.name) print('骨格:',no0.build) print('まぶた:',no0.eyelids) no0.swim() no0.swim_back() no1 = Medaka("魚2号(子クラス)") print(no1.name) print('骨格:',no1.build) print('まぶた:',no1.eyelids) no1.swim() no1.swim_back() # below do not execute class Kingyo(Fish): def __init__(self, name, build="ほね", eyelids=False): self.name = '金魚ちゃん' + name + 'だよ' self.build = build + ' かな' self.eyelids = eyelids
以下がこれまでの当ブログでの表現
WP SyntaxHighlighterが使えたぞ!
今日の前のブログの記事でUPした「WP SyntaxHighlighter」が使えたぞ。
2019年11月15日 @ 20:37にUPした「元号特定プログラム」記事のWP SyntaxHighlighter適用版です。
Function Ad-Conversion($indate){ $ERA_MEIJI = "明治" $ERA_TAISHO = "大正" $ERA_SHOWA = "昭和" $ERA_HEISEI = "平成" $ERA_REIWA = "令和" $DATE_MEIJI = 18680908 $DATE_TAISHO = 19120730 $DATE_SHOWA = 19261225 $DATE_HEISEI = 19890108 $DATE_REIWA = 20190501 if($indate -lt $DATE_MEIJI){ Write-Host("明治以前の日付には対応していません。") }elseif($indate -lt $DATE_TAISHO){ Write-Host("元号は" + $ERA_MEIJI + "です。") }elseif($indate -lt $DATE_SHOWA){ Write-Host("元号は" + $ERA_TAISHO + "です。") }elseif($indate -lt $DATE_HEISEI){ Write-Host("元号は" + $ERA_SHOWA + "です。") }elseif($indate -lt $DATE_REIWA){ Write-Host("元号は" + $ERA_HEISEI + "です。") }else{ Write-Host("元号は" + $ERA_REIWA + "です。") } } Ad-Conversion 19300101 # ① Ad-Conversion 18700101 # ② Ad-Conversion 20190101 # ③ Ad-Conversion 20190502 # ④ Ad-Conversion 20200101 # ⑤ Ad-Conversion 19510817 # ⑥ # 下記は同スクリプトを実行した結果です # 元号は昭和です。① # 元号は明治です。② # 元号は平成です。③ # 元号は令和です。④ # 元号は令和です。⑤ # 元号は昭和です。⑥
上記は元のプログラムと「SYOU」と「SHO」が違っています。
(写真はY.O.氏から借用)
写真はビビハニム・モスクです。
191116
使ってみる
設定が終わったところで、実際に使ってみましょう。投稿画面のビジュアルエディタタブを選択します。
preボタンは、ドラッグした箇所をハイライト対象にしてくれるもの。
codeボタンは、ソースコードを貼り付けて挿入するもの。
わたしは、ほとんどcodeボタンしか使ってませんが、状況に応じて使いわけるといいでしょう。
preボタンの使い方
preボタンの場合は、まずビジュアルエディタにプログラムコードを書き込みます。例として以下のようなhtmlコードを書きました。
こういった直接ビジュアルエディタに書き込んだコードに対してSyntaxHighlighterをあてるには、preボタンを利用します。使い方は、コード全体をドラッグしてpreボタンを押すだけです。
preボタンでhtml言語を選択→「挿入」。
SyntaxHighlighterが適応されます。
テキストで見るとこんな感じ。htmlのハイライトが適応されているのが分かります。
codeボタンの使い方
続いてcodeボタンの使い方。こちらは、コードをそのまま貼り付けたい時に利用します。インデントなどもそのまま維持されます。わたしはローカル環境で動作確認したコードを貼ることがほとんどなので、こちらのcodeボタンを利用するほうが圧倒的に多いです。
codeボタンをクリックします。
言語を選択して、コードを貼り付けます。先ほどと同じhtmlコードを貼り付けてみましょう。
挿入ボタンを押すと、貼り付けたコードがそのまま反映されます。preボタンの時と同じ結果になるのが分かります。
表示
実際の表示をプレビューで見てみましょう。例として作成したコードは以下のように表示されるます。ただし、設定で選択したテーマによって見栄えは異なります。
スポンサード リンク
WP SyntaxHighlighterのいいところ
ソースを切れに表示させるSyntaxHighlighterをWordPressでも簡単に使わせてくれる点はもちろんですが、もう1点。
ショートコードを使わなくていい点がわたしは好きです。他の有名な「SyntaxHighlighter Evolved」はショートコードありきの設計になっています。
わたしはショートコードがあまり好きではなく、それはそのプラグインの開発が終わってしまった途端に(もしくはそのプラグインを利用しなくなった時点で)ゴミのコードになってしまうからですね。
今後のことを考えるとなるべくなら使わない方がいいということで、WP SyntaxHighlighterに軍配をあげています。
おわり
(写真はY.O.氏から借用)
↑人気ブログランキングに参加しています。ポチっと1票を!
Ad-Conversion 20190502④で関数を呼び出し結果を表示する。今回は月日も考慮する。
前に当ブログで西暦、和暦相互変換のプログラムを載せたが、今回はPowerShell_ISEで西暦年月日でその日がどの元号に当たるかを特定するプログラムである。Ad-Conversion 20190502④で関数を呼び出し結果を表示する。今回は月日も考慮する。
Function Ad-Conversion($indate){
$ERA_MEIJI = “明治”
$ERA_TAISYOU = “大正”
$ERA_SYOUWA = “昭和”
$ERA_HEISEI = “平成”
$ERA_REIWA = “令和”
$DATE_MEIJI = 18680908
$DATE_TAISYOU = 19120730
$DATE_SYOUWA = 19261225
$DATE_HEISEI = 19890108
$DATE_REIWA = 20190501
if($indate -lt $DATE_MEIJI){
Write-Host(“明治以前の日付には対応していません。”)
}elseif($indate -lt $DATE_TAISYOU){
Write-Host(“元号は” + $ERA_MEIJI + “です。”)
}elseif($indate -lt $DATE_SYOUWA){
Write-Host(“元号は” + $ERA_TAISYOU + “です。”)
}elseif($indate -lt $DATE_HEISEI){
Write-Host(“元号は” + $ERA_SYOUWA + “です。”)
}elseif($indate -lt $DATE_REIWA){
Write-Host(“元号は” + $ERA_HEISEI + “です。”)
}else{
Write-Host(“元号は” + $ERA_REIWA + “です。”)
}
}
Ad-Conversion 19300101①
Ad-Conversion 18700101②
Ad-Conversion 20190101③
Ad-Conversion 20190502④
Ad-Conversion 20200101⑤
Ad-Conversion 19510817⑥
*******************************************************
PS C:\Users\prog> C:\Users\prog\Desktop\File\Gengo.ps1
元号は昭和です。①
元号は明治です。②
元号は平成です。③
元号は令和です。④
元号は令和です。⑤
元号は昭和です。⑥
*************以下は実行結果
(写真はY.O.氏から借用)
スクリプトはPowerShell_ISEで行ったものでありUSBの装置名の違いを吸収した例です。実際に実行済み!
以下のスクリプトはPowerShell_ISEで行ったものでありUSBの装置名の違いを吸収した例です。
実際に実行済み!
Path、Folder名は変えてあります。
# BackUpEtoUSB
$date = Get-Date -UFormat “%Y年%B%d日 %H:%M:%S”
Write-Host “Start” $date
Write-Host “BackUp USB Memoryはすでにフォーマットしてありますか?F or GにUSBを挿入してください。”
Write-Host “緑のUSBはF装置または黒のUSBはG装置どちら?”
[ValidateLength(1,10)]$Dev = [String](Read-Host “USBの装置IDは?F or G=”)
If ($Dev -eq ‘F’ -or $Dev -eq ‘G’){
Write-Host “BackUp USB Memoryは正しい装置IDです。”
}Else{
Write-Host “間違った装置IDです。「重要な処理です、続けますか?」にはNと答えてください。”
}
Write-Host “緑のUSBはすでにフォルダーCG-B,osource,File,洋楽,Desktop,画像,動画,資料を削除してありますか?”
Write-Host “次のメッセージに11文字以上を入力すると結果は保証されません、Yと判断されるときもあります!”
[ValidateLength(1,10)]$Rep = [String](Read-Host “重要な処理です、続けますか?Y or N=”)
If ($Rep -eq ‘Y’){
Set-Location C:\Users\Prog\Desktop\Smpl
If (-not(Test-Path ($Dev + “:\” + “洋楽”))){
New-Item ($Dev + “:\” + “洋楽”) -ItemType Directory
}
If (-not(Test-Path ($Dev + “:\” + “画像”))){
New-Item ($Dev + “:\” + “画像”) -ItemType Directory
}
If (-not(Test-Path ($Dev + “:\” + “動画”))){
New-Item ($Dev + “:\” + “動画”) -ItemType Directory
}
If (-not(Test-Path ($Dev + “:\” + “資料”))){
New-Item ($Dev + “:\” + “資料”) -ItemType Directory
}
If (-not(Test-Path ($Dev + “:\” + “Desktop”))){
New-Item ($Dev + “:\” + “Desktop”) -ItemType Directory
}
If (-not(Test-Path ($Dev + “:\” + “File”))){
New-Item ($Dev + “:\” + “File”) -ItemType Directory
}
If (-not(Test-Path ($Dev + “:\” + “CG-B”))){
New-Item ($Dev + “:\” + “CG-B”) -ItemType Directory
}
If (-not(Test-Path ($Dev + “:\” + “osource”))){
New-Item ($Dev + “:\” + “osource”) -ItemType Directory
}
$indir = “C:\Users\Prog\Desktop\”
$outdir = ($Dev + “:\” + “Desktop”)
$date = Get-Date -UFormat “%y%m%d”
Get-ChildItem $indir | Foreach-Object {
$infile = $indir + “\” + $_.name
$outfile = $outdir + “\” + $_.name
Copy-Item $infile -Destination $outfile -Recurse
}
$indir = “C:\Users\Prog\AppData\Local\Programs\File\”
$outdir = ($Dev + “:\” + “File”)
$date = Get-Date -UFormat “%y%m%d”
Get-ChildItem $indir | Foreach-Object {
$infile = $indir + “\” + $_.name
$outfile = $outdir + “\” + $_.name
Copy-Item $infile -Destination $outfile -Recurse
}
$indir = “E:\191115BackUpD\画像\雄三\Snipping\snippingToshiba\”
$outdir = ($Dev + “:\” + “画像”)
$date = Get-Date -UFormat “%y%m%d”
Get-ChildItem $indir | Foreach-Object {
$infile = $indir + “\” + $_.name
$outfile = $outdir + “\” + $_.name
Copy-Item $infile -Destination $outfile -Recurse
}
$indir = “E:\191115BackUpD\資料\”
$outdir = ($Dev + “:\” + “資料”)
$date = Get-Date -UFormat “%y%m%d”
Get-ChildItem $indir | Foreach-Object {
$infile = $indir + “\” + $_.name
$outfile = $outdir + “\” + $_.name
Copy-Item $infile -Destination $outfile -Recurse
}
$indir = “C:\Users\Prog\CG-B\”
$outdir = ($Dev + “:\” + “CG-B”)
$date = Get-Date -UFormat “%y%m%d”
Get-ChildItem $indir | Foreach-Object {
$infile = $indir + “\” + $_.name
$outfile = $outdir + “\” + $_.name
Copy-Item $infile -Destination $outfile -Recurse
}
$indir = “C:\Users\Prog\osource\”
$outdir = ($Dev + “:\” + “osource”)
$date = Get-Date -UFormat “%y%m%d”
Get-ChildItem $indir | Foreach-Object {
$infile = $indir + “\” + $_.name
$outfile = $outdir + “\” + $_.name
Copy-Item $infile -Destination $outfile -Recurse
}
}
$date = Get-Date -UFormat “%Y年%B%d日 %H:%M:%S”
Write-Host “End” $date
以上