202610 VS Code GitHub AI 開發 HPE NonStop (TANDEM) COBOL
Setup
1.安裝 VS CODE
VSCodeUserSetup-x64-1.138.0.exe
2.安裝 extension (延伸模組)
套件列表如下:
Chinese (Traditional) Language Pack:VS Code 的中文 (繁體) 語言套件
COBOL Source editing for Visual Studio Code (BitLang):
為 COBOL語言提供 智慧感知、高亮顯示、程式碼片段和程式碼瀏覽功能
Git Graph:強大視覺化 Git 樹狀圖。
GitLens — Git supercharged : 強大視覺化 Git 管理介面
EditorConfig for VS Code:自動將所有 CRLF 換行轉為乾淨的 LF。
Markdown Preview Enhanced:Markdown檔案預覽
3.安裝node.js
node-v24.15.0-x64.msi
設定
1.設定為中文介面
(1) 按下ctrl-alt-p 或者選 檢視->命令選擇區
(2) 在命令欄輸入 Language, 選擇Configure Display Language
(3) 選擇繁體中文後,重新啟動
2.設定 .vscode\settings.json 預設值檔案
如果您只想針對「目前開發的 HPE NonStop COBOL 專案資料夾」設定,
不想影響到其他普通的寫程式專案,您可以這樣做:
a.在 VS Code 開啟你的專屬工作資料夾,例如 D:\cobol_workspace
b. 在資料夾內建立一個名為 .vscode 的隱藏資料夾
c. 在 .vscode 內建立一個 settings.json 檔案
設定內容如下
{
"files.associations": { // 設定檔案關聯,讓 VS Code 能正確識別無副檔名的 COBOL 檔案
"**/SRC_FU/FUCOPY/[!.]*": "COBOL", // [!.]* 代表匹配檔名中不包含 .(小數點)的任何檔案
"**/SRC_FU/FUCOPYM/[!.]*": "COBOL",
"**/SRC_FU/APCOPY/[!.]*": "COBOL",
"**/SRC_FU/FUDDL/[!.]*": "COBOL",
"**/SRC_FU/FUBS/[!.]*": "COBOL",
},
"files.defaultLanguage": "COBOL", // 設定預設檔案語言為 COBOL
// 指定 COBOL 語言特定設定
"[COBOL]": {
"files.encoding": "cp950", // 設定檔案編碼為 cp950 (Big5)
"files.autoGuessEncoding": false, // 關閉自動猜測檔案編碼,強制使用指定的編碼 (cp950)
"editor.autoIndent": "advanced", // 啟用進階自動縮排
"editor.bracketPairColorization.enabled": true, // 啟用括號配對顏色化
"editor.formatOnSave": false, // 關閉儲存時自動排版(避免傳統 Linter 把程式碼強行對齊第 8 欄、第 12 欄)
"editor.insertSpaces": true, // 自動將 Tab 轉換為空白
"editor.rulers": [5, 29] , // 第 5,29 個字元處放一條淡淡的輔助線
"editor.semanticHighlighting.enabled": true, // 啟用語義高亮顯示
"editor.snippetSuggestions": "bottom", // 將程式碼片段建議顯示在建議清單的底部
"editor.tabSize": 3, // 採用 格空白縮排(符合 Free-form 易讀性)
"editor.wordSeparators": "`~!@#$%^&*()=+[{]}\\|;:'\",.<>/?-" // 設定單詞分隔符,確保減號「-」能正確分離變數名稱(如 WS-MESSAGE)
},
// 設定 COBOL 編輯器的檔案格式
"coboleditor.fileformat": [{
"sourceformat": "free" // 設定 COBOL 檔案的來源格式為自由格式 (Free-form)
}],
"coboleditor.tabstops": [2,20] , // 自訂縮排停靠點,第一個停靠點在第 2 欄,第二個停靠點在第 20 欄
"coboleditor.enable_exec_sql_cursors": false, // 是否啟用 EXEC SQL Cursors 功能
"coboleditor.valid_cobol_language_ids": ["COBOL"], // 設定有效的 COBOL 語言識別碼
"coboleditor.workspacefolders_order": ["cobol_workspace"], // 設定工作區資料夾的順序
"coboleditor.copybookdirs": ["$FUCOPY","$FUCOPYM","$APCOPY","$FUDDL"], // 設定 COBOL 的 copybook 目錄
"coboleditor.enable_minimap_section_boundaries": true, // 在縮圖中顯示區段邊界
"coboleditor.enable_minimap_section_boundaries_for_sections": true, // 在縮圖中顯示區段邊界
"coboleditor.enable_minimap_section_boundaries_for_paragraphs": true, // 在縮圖中顯示段落邊界
"coboleditor.enable_minimap_section_boundaries_for_divisions": true, // 在縮圖中顯示區塊邊界
"coboleditor.intellisense_add_space_keywords":[
"ACCEPT",
"ADD",
"COMPUTE",
"DISPLAY",
"EVALUATE",
"END-IF",
"IF",
"INITIALIZE",
"PERFORM",
"MOVE"
],
"coboleditor.margin":false, // 關閉 COBOL 編輯器的邊距 (第 73-80 列 的顏色將不再顯示)
"coboleditor.margin_identification_area": false, // 關閉 COBOL 編輯器的標識區域邊距(固定格式原始檔的識別區域(第 73-80 列)將被視為註釋)
"coboleditor.minimap_section_colors": { // 設定縮圖中各區段的顏色
"division": { "light": "#FF6F00", "dark": "#FFB74D", "alpha": 0.08 },
"section": { "light": "#0066CC", "dark": "#4FC3F7", "alpha": 0.05 },
"paragraph": { "light": "#8E24AA", "dark": "#CE93D8", "alpha": 0.03 }
} ,
"coboleditor.comments_tags": [ // 設定 COBOL 註解標籤的顏色與樣式
{
"tag": " ?",
"color": "#3498DB",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": " * ",
"color": "#98C379",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": " //",
"color": "#474747",
"strikethrough": true,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
}
],
// 啟用並強制 GitHub Copilot 在 COBOL 環境下運作
"github.copilot.enable": {
"*": true, // 啟用 GitHub Copilot 在所有語言環境下運作
"COBOL": true, // 啟用 GitHub Copilot 在 COBOL 環境下運作
"plaintext": false,
"BITLANG-COBOL": false,
"COBOLIT": false,
"ACUCOBOL": false,
"RMCOBOL": false,
"COBOL_MF_LISTFILE": false,
"COBOL_PCOB_LISTFILE": false,
"COBOL_ACU_LISTFILE": false,
"COBOL_MF_PREP": false,
"mfu": false,
"utreport": false
}
}
3.設定 \.github\copilot-instructions.md
# 語言約束指令
- 在所有的思考過程、任務規劃(Todos)、程式碼註解以及對話回覆中,請一律強制使用「繁體中文(zh-TW)」
- 變數名稱、函數名稱、類別名稱一律使用英文
- 註解、變數說明使用繁體中文敘述
- 變數一律大寫
- 修改的部份須加上修改日期、修改者、註解
- git commit 一律使用繁體中文敘述
# GitHub Copilot Custom Instructions for HPE NonStop (Tandem) COBOL
You are an expert developer specializing in **HPE NonStop (formerly Tandem) COBOL** (supporting COBOL85 and ECOBOL/NMCOBOL/XCOBOL). You generate highly optimized, standard-compliant code tailored specifically for the HPE NonStop Guardian and OSS environments.
## 1. Code Formatting Standards (CRITICAL)
Always use the **Tandem Format (Free-form / Entry-sequenced text style)**. Do NOT use the traditional IBM/ANSI Fixed Reference Format unless explicitly requested.
* **No Sequence Numbers:** Do NOT add line numbers or sequence numbers in columns 1-6. Code starts immediately at column 1.
* **Indicator Area (Column 1):**
* For comments, place an asterisk `*` or slash `/` in the **very first character/column (Column 1)** of the line.
* For line continuation, use a hyphen `-` in Column 1 (though modern Tandem format rarely needs it due to free-form alignment).
* **Area A & Area B Flexibility:**
* Do NOT strictly enforce the Column 8 (Area A) and Column 12 (Area B) boundaries.
* **Divisions, Sections, Paragraphs, and level-01 / level-77 variables** should simply start at the beginning of the line (Column 1 or indented slightly for readability).
* **Statements, body clauses, and subordinate levels (05, 10, etc.)** should be indented relative to their parent elements using standard spaces (e.g., 3 or 4 spaces) to separate them from paragraph headers.
* **No Line Truncation:** Do NOT pad lines with trailing spaces up to column 72 or 80. Lines can end naturally after the last character.
## 2. HPE NonStop Specific Conventions
When generating or refactoring code, always adhere to NonStop OS paradigms:
* **File Handling (Enscribe / OSS):**
* Ensure proper `SELECT ... ASSIGN TO` syntax mapping to Tandem logical file names (e.g., `SELECT MY-FILE ASSIGN TO "$DATA.SUBVOL.MYFILE"` or dynamic names).
* Be ready to handle Enscribe file status codes (e.g., checking for status "00", "10", or specific Tandem file system errors like error 12, 45).
* **System Calls:** Use standard Tandem system procedures (e.g., `PROCESS_DELAY_`, `NUMOUT_`, `REPLY_`) with proper `ENTER TAL` or external linkage parameters if requested.
## 3. Code Generation Example Reference
Use this exact style as a baseline template for generating any new COBOL files or paragraphs:
```cobol
COPY MAIN-DIRECTIVE OF "APCOPY.COBDIR".
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-TANDEM.
*AUTHOR. RICK.
*DATE-WRITTEN. 20260728.
******************************************************************************
* 程式目的 : SAMPLE TANDEM-FORMAT COBOL FOR HPE NONSTOP
******************************************************************************
*UPDATE-HISTORY.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-VARIABLES.
05 WS-MESSAGE PIC X(20) VALUE "HELLO NONSTOP!".
05 WS-STATUS PIC X(02) VALUE "00".
PROCEDURE DIVISION.
MAIN-PROCEDURE.
DISPLAY WS-MESSAGE
STOP RUN.
```
## 4. Response Tone and Output Constraints
* **Direct Code Delivery:** Provide clean, ready-to-paste Tandem COBOL code blocks without inserting artificial `123456` column indicators or ruler lines.
* **Explain NonStop Context:** When explaining code logic, mention NonStop-specific behaviors (such as Guardian file systems or TACL variable interactions) where relevant.
* ** 若是修改程式,須在 "*UPDATE-HISTORY." 段落標註修改備註 and 在修改程式處也標註修改備註,格式為 西元日期+修改備註.
設定完成後
開啟 COBOL 程式
1.若 VS CODE 有偵測此程式語言是 COBOL時
右下角 會顯示 "Big5 CRLF {} COBOL"
若顯示 "純文字" ==> 檢查 .vscode\settings.json 的 "files.associations"
檔案關聯是否設錯
2.程式語言是 COBOL時
COBOL Source editing for Visual Studio Code (BitLang) 延伸模組
會提供 智慧感知、高亮顯示、程式碼片段和程式碼瀏覽功能