{"id":"iec-mid","model_id":"MID","name":"CODESYS MID","summary":"MID is a string function in the CODESYS Standard library that returns a specified number of characters from a string, starting from a given position. It is called as MID(STR, LEN, POS): take LEN characters from STR beginning with the character at position POS, and return the partial string. The function is declared as FUNCTION MID : STRING(255).","study_notes":["Declared as FUNCTION MID : STRING(255), so the returned partial string can be up to 255 characters.","All three arguments are inputs: STR (STRING(255)), LEN (INT) and POS (INT).","The source example VarSTRING1 := MID('SUSI',2,2); returns 'US'.","LEN is documented as the number of characters, counted from the left; POS is the start position for the partial string."],"safety_notes":[],"sources":[{"url":"https://infosys.beckhoff.com/content/1033/tcplclib_tc2_standard/74420235.html","title":"Beckhoff Information System","accessed":"2026-10-26"},{"url":"https://content.helpme-codesys.com/en/libs/Standard/Current/String-Functions/MID.html","title":"CODESYS Group","accessed":"2026-10-26"}],"verification":{"status":"source_checked","checked_at":"2026-10-26","values":12,"method":"llm_source_check"},"updated_at":"2026-10-26","type":"instruction","spec":{"language":"iec_61131_3","code":"MID","group":"String Functions","syntax":"MID (STR, LEN, POS)","parameters":[{"name":"STR","data_type":"STRING(255)","description":"String to be analyzed"},{"name":"LEN","data_type":"INT","description":"Number of characters, counted from the left"},{"name":"POS","data_type":"INT","description":"Start position for the partial string"}],"dialect":"CODESYS","related":[],"standards":[]},"url":"https://machineschema.com/instruction/iec-mid","license":"https://creativecommons.org/licenses/by/4.0/"}