Press enter to see results or esc to cancel.

System Procedure Assign

This function processes system procedure Assign.

Function Proc_Assign: Word; Far;
Var FileExpression, FileNameExpression: TExpression;
begin
  ExpectTokenAndGetNext (Token_LeftParenthesis);
  FileExpression.ExpectFileVariableAndPushPointerToMemory;
  ExpectTokenAndGetNext (Token_Comma);
  FileNameExpression.ExpectAndStoreStringCompatibleExpressionAndPushPointer;
  ExpectTokenAndGetNext (Token_RightParenthesis);
  StoreCode_icGoSub (FileExpression.IntermediateCodeOffset);
  StoreCode_icGoSub (FileNameExpression.IntermediateCodeOffset);
  Case FileExpression.TypeDefPtr^.BaseType of
    btFile: Case FileNameExpression.TypeDefPtr^.BaseType of
              btString: GenerateInstruction_CALL_FAR (SysProc_AssignFile);
              else      GenerateInstruction_CALL_FAR (SysProc_AssignFileC);
            end;
    else Case FileNameExpression.TypeDefPtr^.BaseType of
           btString: GenerateInstruction_CALL_FAR (SysProc_AssignText);
           else      GenerateInstruction_CALL_FAR (SysProc_AssignTextC);
         end;
  end;
  Proc_Assign := EndSubroutine;
end;