Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/694305e8-d7f8-800e-a8d8-fbf410be6545
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: 結論からいくね。 === 結論からいくね。 '''COBOLでファイルパスを書くときは「OS依存・処理系依存」'''で、 C系みたいな共通ルールはない。 ==== : ==== だから * Windows COBOL * Unix/Linux COBOL * メインフレーム COBOL で 全部違う。 ==== ### ==== <syntaxhighlight lang="cobol">SELECT INFILE ASSIGN TO "C:\data\input.txt". </syntaxhighlight> * \ は ただの文字 * \\ にする必要は ない * C系と違って楽 ===== <syntaxhighlight lang="cobol">"C:/data/input.txt" ===== </syntaxhighlight> * 処理系次第 * 通ることもあるが 保証なし 👉 安全策:<code>\</code> を使う ==== <syntaxhighlight lang="cobol">SELECT INFILE ASSIGN TO "/home/user/input.txt". ==== </syntaxhighlight> * / が正式 * \ は通常使わない ==== ### ==== <syntaxhighlight lang="cobol">SELECT INFILE ASSIGN TO DDNAME. </syntaxhighlight> JCL 側: <syntaxhighlight lang="jcl">//DDNAME DD DSN=USER.DATA.FILE,DISP=SHR </syntaxhighlight> * COBOLソースにパスを書かない * OS側(JCL)に任せる ==== | | | ==== | --- | --- | | | | | | | | | | ==== ### ==== <syntaxhighlight lang="cobol">01 WS-PATH PIC X(256). MOVE "C:\data\input.txt" TO WS-PATH. SELECT INFILE ASSIGN TO WS-PATH. </syntaxhighlight> * \ をそのまま書ける * 可変対応 ==== <syntaxhighlight lang="json">{ "path": "C:\\data\\input.txt" } ==== </syntaxhighlight> COBOL側: <syntaxhighlight lang="cobol">MOVE JSON-PATH TO WS-PATH. </syntaxhighlight> * COBOLは \ を2文字として保持 * OSが解釈するときに初めて意味が出る ==== 1. COBOL内では \ はエスケープしない ==== # OSが期待する記法を書く # メインフレームではパスを書かない # 外部仕様(JSON等)は外部仕様に従う ==== : ==== だから COBOLは * 簡単にもなる * 事故源にもなる もし次に行くなら * GnuCOBOLでの実例 * Windows ↔ Unix 移植時の地雷 * JCLとCOBOLの責務分離 どれ行く?
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)