/→\ コード変換サンプル
- テスト結果の表示
- 入力:
- 置換:
ソース
function GetPathName(strFileName) {
//デバッグ: id fooに入力テキストと文字数を表示
document.getElementById("foo").textContent = strFileName + ' 文字数:' + strFileName.length;
var inPos
var strPathOnly
var intLoopCount
var pointx
var pointx2
var pointx3
inPos = strFileName.length; // strFileNameの長さ
//すべての'/'記号を'\'記号に変更します。
strFileName = strFileName.replaceAll( "/" , "\\" ); // 置換結果
pointx = strFileName.indexOf("\\") + 1; // \がstrFileName文字列の左から何番目にある?
// デバッグ: 置換結果の表示と¥は何番目?
document.getElementById("foo2").textContent = strFileName + ' \\は何番目:' + pointx;
if (pointx = inPos) { // \の位置が文字列の文字数(¥が文字列の末尾なら)
if (inPos > 1) inPos = inPos - 1; // 文字数が1以上ならinPos(文字列の文字数を1引く)
} else { // \の位置が文字列の文字数っではない時
do {
if (strFileName,subst(inPos, 1) !== "\\") {
inPos = inPos - 1;
} else {
break;
}
} while (inPos > 0);
}
console.log("inPos : ", inPos); // inPosの数
if (inPos > 0) { // nPosが0以上なら
strPathOnly = strFileName.substr(inPos);
pointx2 = strPathOnly.slice(-1);
console.log(strPathOnly, pointx2); // strFileNameの末尾の文字
// if (pointx2 = ":") {
if (strPathOnly.slice(-1) = "\:") {
strPathOnly = strPathOnly + "\\";
}
} else {
strPathOnly = CuDir;
}
pointx3 = strPathOnly.slice(1);
console.log(strPathOnly, pointx3); // strFileNameの末尾の文字
/*
if (pointx3 = "\\") {
strPathOnly = strPathOnly.slice(strPathOnly.length - 1);
}
*/ GetPathName = strPathOnly;
return GetPathName;
}
//デバッグ: id fooに入力テキストと文字数を表示
document.getElementById("foo").textContent = strFileName + ' 文字数:' + strFileName.length;
var inPos
var strPathOnly
var intLoopCount
var pointx
var pointx2
var pointx3
inPos = strFileName.length; // strFileNameの長さ
//すべての'/'記号を'\'記号に変更します。
strFileName = strFileName.replaceAll( "/" , "\\" ); // 置換結果
pointx = strFileName.indexOf("\\") + 1; // \がstrFileName文字列の左から何番目にある?
// デバッグ: 置換結果の表示と¥は何番目?
document.getElementById("foo2").textContent = strFileName + ' \\は何番目:' + pointx;
if (pointx = inPos) { // \の位置が文字列の文字数(¥が文字列の末尾なら)
if (inPos > 1) inPos = inPos - 1; // 文字数が1以上ならinPos(文字列の文字数を1引く)
} else { // \の位置が文字列の文字数っではない時
do {
if (strFileName,subst(inPos, 1) !== "\\") {
inPos = inPos - 1;
} else {
break;
}
} while (inPos > 0);
}
console.log("inPos : ", inPos); // inPosの数
if (inPos > 0) { // nPosが0以上なら
strPathOnly = strFileName.substr(inPos);
pointx2 = strPathOnly.slice(-1);
console.log(strPathOnly, pointx2); // strFileNameの末尾の文字
// if (pointx2 = ":") {
if (strPathOnly.slice(-1) = "\:") {
strPathOnly = strPathOnly + "\\";
}
} else {
strPathOnly = CuDir;
}
pointx3 = strPathOnly.slice(1);
console.log(strPathOnly, pointx3); // strFileNameの末尾の文字
/*
if (pointx3 = "\\") {
strPathOnly = strPathOnly.slice(strPathOnly.length - 1);
}
*/ GetPathName = strPathOnly;
return GetPathName;
}