github.com/archlabjp/eeslism-go@v0.0.0-20231109122333-4bb7bfcdf292/eeslism/esidcode_s.go (about) 1 //This file is part of EESLISM. 2 // 3 //Foobar is free software : you can redistribute itand /or modify 4 //it under the terms of the GNU General Public License as published by 5 //the Free Software Foundation, either version 3 of the License, or 6 //(at your option) any later version. 7 // 8 //Foobar is distributed in the hope that it will be useful, 9 //but WITHOUT ANY WARRANTY; without even the implied warranty of 10 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 11 //GNU General Public License for more details. 12 // 13 //You should have received a copy of the GNU General Public License 14 //along with Foobar.If not, see < https://www.gnu.org/licenses/>. 15 16 /* esidcode_s.c */ 17 18 package eeslism 19 20 import ( 21 "errors" 22 "fmt" 23 ) 24 25 /* スケジュ-ル名からスケジュ-ル番号の検索 */ 26 /* --------------------------------------------*/ 27 28 // 季節設定の検索 29 func idssn(code string, _Seasn []SEASN) (int, error) { 30 N := len(_Seasn) 31 32 for j := 0; j < N; j++ { 33 Seasn := &_Seasn[j] 34 if code == Seasn.name { 35 return j, nil 36 } 37 } 38 39 return -1, errors.New("SEASN Not Found") 40 } 41 42 /* ---------------------------------------- */ 43 44 // 曜日設定の検索 45 func idwkd(code string, Wkdy []WKDY) (int, error) { 46 for j := 0; j < len(Wkdy); j++ { 47 _Wkdy := &Wkdy[j] 48 if code == _Wkdy.name { 49 return j, nil 50 } 51 } 52 53 return -1, errors.New("WKDY Not Found") 54 } 55 56 /* ---------------------------------------- */ 57 58 // 一日の設定値スケジュ-ルの検索 59 func iddsc(code string, Dsch []DSCH) (int, error) { 60 N := len(Dsch) 61 62 for j := 0; j < N; j++ { 63 _Dsch := &Dsch[j] 64 if code == _Dsch.name { 65 return j, nil 66 } 67 } 68 69 return -1, errors.New("DSCH Not Found") 70 } 71 72 /* ---------------------------------------- */ 73 74 // 一日の切り替えスケジュ-ルの検索 75 func iddsw(code string, Dscw []DSCW) (int, error) { 76 N := len(Dscw) 77 78 for j := 0; j < N; j++ { 79 _Dscw := &Dscw[j] 80 if code == _Dscw.name { 81 return j, nil 82 } 83 } 84 85 return -1, errors.New("DSCW Not Found") 86 } 87 88 /* ---------------------------------------- */ 89 90 /* ---------------------------------------- */ 91 92 // 93 // スケジュールcodeを Sch から検索し、インデックス番号を返す 94 // ただし、検索しても見つからない場合は -1 を返す 95 func idsch(code string, Sch []SCH, err string) (int, error) { 96 N := len(Sch) 97 98 if N != len(Sch) { 99 panic("N != len(Sch)") 100 } 101 102 for j := 0; j < N; j++ { 103 _Sch := &Sch[j] 104 if code == _Sch.name { 105 return j, nil 106 } 107 } 108 109 if err != "" { 110 Eprint("<idsch>", err) 111 } 112 return -1, errors.New("Schedule Not Found") 113 } 114 115 /* ---------------------------------------- */ 116 117 // スケジュールcodeを Scw から検索し、インデックス番号を返す 118 // ただし、検索しても見つからない場合は -1 を返す 119 func idscw(code string, Scw []SCH, err string) (int, error) { 120 N := len(Scw) 121 122 if N != len(Scw) { 123 panic("N != len(Scw)") 124 } 125 126 for j := 0; j < N; j++ { 127 _Scw := &Scw[j] 128 if code == _Scw.name { 129 return j, nil 130 } 131 } 132 133 if err != "" { 134 Eprint("<idscw>", err) 135 } 136 return -1, errors.New("Schedule Not Found") 137 } 138 139 /* ---------------------------------------- */ 140 141 // 室名 `code` に一致する部屋を 部屋の一覧 `Room` から検索し、その番号を返す 142 // ただし、検索しても見つからない場合はエラーを返す 143 func idroom(code string, rooms []*ROOM, err string) (int, error) { 144 for j := range rooms { 145 _Room := rooms[j] 146 if code == _Room.Name { 147 return j, nil 148 } 149 } 150 151 E := fmt.Sprintf("Room=%s %s", code, err) 152 Eprint("<idroom>", E) 153 154 return -1, errors.New("Room Not Found") 155 } 156 157 /* ---------------------------------------- */ 158 159 /* ---------------------------------------- */