| Quick Web Site Guide |
|
|---|
| C Tutorial #4 |
#include <stdio.h>
#include <clib/intuition_protos.h>
#include <clib/asl_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
struct FileRequester *fReq;
int main(void)
{
struct Library *IntuitionBase;
struct Library *AslBase;
int test;
BOOL result;
STRPTR filnam, drnam;
IntuitionBase=OpenLibrary("intuition.library",0);
AslBase=OpenLibrary("asl.library",0);
fReq=AllocFileRequest();
result=RequestFile(fReq);
if(result==FALSE){
printf("Error in selecting\n");
}else{
filnam=fReq->fr_File;
drnam=fReq->fr_Drawer;
printf("The file which was selected is:%s%s.\n", drnam,filnam);
};
scanf("%d", &test);
CloseLibrary(IntuitionBase);
CloseLibrary(AslBase);
return 0;
}
| ��������� ������� |
| struct <.....> <.....> |
���� � ������ ���������� ����� ��� ������ �� �������� ���� ���� �� ��������������� ����� ���
�� ��������� �� ������������ ��� ����������� (�������). ��� �� ����� struct FileRequester *fReq; �� ������� ����� ��� �� *fReq ����� ����� ���� ��� �������� ��� ������� ������ ��� �������� ���� ���� �� ������ �� �������� �� ������������ ��� ��� AllocFileRequest() ������ � AllocFileRequest() ���������� ��� ���� ��� ����������� ���� ����������, ������ �� ������� ��� � ��������� ������������� ����� ���� ����� ��� �� ��� ��������. �����; � ������ �� ��� struct �������������� �� ��������� ����� ���� �� ����� ���� �� �������� ���� �� �� ���������������� ��������. |
| BOOL result; |
���� �� �� ������������ ��� ��� ���� �������� ��� ��������� ��� ����� Boolean. ������ ���� �������� ��� ���� � ��������� ������ �� ����� ���� 2 ����� ��� ����� ��: TRUE/FALSE. ���� ��������� �� ���������� ��� RequestFile(fReq) �� ����� ������ � ��� ��� ������� ���������� ��� ������� ��� requester � �� ����� �� ���������� ��� �������� ��� ����� �����, ���� ��� ����� � ��������� FALSE ����� ��� ��������� �� ��������� ������ ��� �� ��������� ��������� ����� �� ��� ����� �� ������ ��� ������������ �� ����������. |
| STRPTR filnam, dirnam; |
����� � ������� STRING POINTER. �� ����� ��� ������ ����� ������� ��� ��������� ����� �� �������� ������������� ��������. |
| OpenLibrary("LibName.library", 0) |
���� ��������� ��� �� ����� ���� � ��������� ������� ��� ���������� ��� �� ���������� �� ����������������
��� ��� ������� ����������� ��� ��������. �� LibName.library ����� �� ����� ��� ���������� ��� � ������� 0 ������� ���� version ��� ���������� ������� �� ����������������. �� ��������� ��� ������� 0 ���� ��� ��� ����������, ���� ������ ����� version ������� ��� ��� ������ ������������. ����� ���� ������������ � ��������� ���� ����� ������ ���������� ��� �������� �� ��� struct ����� Library. ������ ��� ���� ������������ ��� ���� �� ��������� ����� ��� �� �������� �� ������������ ��� ���������� ��� �����������. ���� ����� ���� �� ������������ ����� ������ ����������� ��� �� ������� ��� ��� ���� ������� �� ���� �� ������� coder. |
| filnam=fReq->fr_File; |
����� ����� � ������ ��������� �� ��� ����� ���� �����! ������ �� ���� ��� ����� ��� ������������ ���������� ���� ���� ��������� filnam �� ����������� ��� ������ fr_File ��� ����� fReq � ����� ���� ���� �� ���������� ��� �������� ��� ��� ����� ���� ������ �� �� ��� ��� file requester. �� fr_File ����� ��� �������� ���� ���� ���� ��� ��� ������ ��� ������ ��� �� fReq! �� ���� ��������� ��� �� ��� dirnam. |
| CloseLibrary(LibName) |
����� ���� ��� ������������ ���� ��� ���������� ��� ������ ��� ����� ��� ������������, ��� ������
���� �� ������� �� ��������� ��� ����������� ��� �������� ���� ���� �� ��������������� ��� �����
��� ����� �������������! ��� ���� ������� �� ��� ������������ ���������. |
| C Tutorials | C Tutorial #1 | C Tutorial #2 | C Tutorial #3 | C Tutorial #4 |
|---|