asltest.pas 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {
  2. Using an asl.library requester
  3. Free Pascal for MorphOS example
  4. Copyright (C) 2005 by Karoly Balogh
  5. Based on work of Nils Sjoholm
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program 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.
  11. **********************************************************************}
  12. { * 2005.01.30 * }
  13. { * Needs MorphOS RTL 2005.01.30 or later! * }
  14. program ASLtest;
  15. uses exec, intuition, utility, asl;
  16. function MessageBox(title, txt, gad: String) : LongInt;
  17. var
  18. tmpReq: TEasyStruct;
  19. begin
  20. title:=title+#0;
  21. txt:=txt+#0;
  22. gad:=gad+#0;
  23. with tmpReq do begin
  24. es_StructSize:=SizeOf(tEasyStruct);
  25. es_Flags:=0;
  26. es_Title:=@title[1];
  27. es_TextFormat:=@txt[1];
  28. es_GadgetFormat:=@gad[1];
  29. end;
  30. MessageBox:=EasyRequestArgs(NIL,@tmpReq,NIL,NIL);
  31. end;
  32. var
  33. FileReq : PFileRequester;
  34. aslResult: Boolean;
  35. begin
  36. { * Opening needed libraries * }
  37. InitIntuitionLibrary;
  38. InitAslLibrary;
  39. FileReq:=AllocAslRequestTags(ASL_FileRequest,[
  40. ASLFR_InitialPattern,DWord(PChar('#?')),
  41. ASLFR_TitleText,DWord(PChar('ASL Requester Test')),
  42. ASLFR_DoPatterns,DWord(True),
  43. TAG_DONE]);
  44. if FileReq<>NIL then begin
  45. aslResult:=AslRequest(FileReq,NIL);
  46. if aslResult then
  47. MessageBox('ASL Test Results',
  48. 'The path is: '+FileReq^.rf_Dir+#10+
  49. 'And the file is: '+FileReq^.rf_File,
  50. 'OK')
  51. else
  52. MessageBox('ASL Test Result',
  53. 'You canceled!',
  54. 'OK');
  55. FreeAslRequest(FileReq);
  56. end;
  57. end.