Recent

Author Topic: FileManager  (Read 3606 times)

Gilles

  • New Member
  • *
  • Posts: 37
FileManager
« on: October 17, 2018, 02:30:48 pm »
Hello

Je n'y arrive pas. It is so difficult to learn a new langage (objective P) and new routines …
I need a model.

This is a simple program I use to read a string from a file, starting at L_beg and having x_cnt characters.
It would be marvellous if somebody could translate it in a new form of langage. Just a model to understand how it works (just a procedure doing the same thing) :

Code: Pascal  [Select][+][-]
  1. function f_ReadStringFromACloseFile (xx_ref: FSRef;
  2.                                      L_beg: SInt64; x_cnt: SInt16; var S: string): OSErr;
  3.     var
  4.         xx_dfn: HFSUniStr255;
  5.         xx_fkp: FSForkIOParam;
  6.         xErr, yErr: OSErr;
  7.         x_rfn: FSIORefNum;
  8. begin
  9.     S := '';
  10.  
  11.     xErr := FSGetDataForkName(xx_dfn);
  12.  
  13.      if xErr = noErr then
  14.         xErr := FSOpenFork(xx_ref, xx_dfn.length, @xx_dfn.unicode, fsRdPerm, x_rfn);
  15.  
  16.     if xErr = noErr then
  17.     begin
  18.         xx_fkp.forkRefNum := x_rfn;
  19.         xx_fkp.buffer := @S;
  20.         xx_fkp.requestCount := x_cnt + 1;
  21.         xx_fkp.positionMode := noCacheMask + fsFromStart;
  22.         xx_fkp.positionOffset := L_beg;
  23.  
  24.         xErr := PBReadForkSync(xx_fkp);
  25.         yErr := FSCloseFork(x_rfn);
  26.  
  27.         if xErr = noErr then
  28.             xErr := yErr
  29.     end;
  30.  
  31.     f_ReadStringFromACloseFile := xErr
  32. end;
  33.  
TurboPascal -> ThinkPascal -> CodeWarrior -> XCode with FPC -> (Well-deserved) Retirement (but not yet, not yet…)

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: FileManager
« Reply #1 on: October 17, 2018, 04:12:45 pm »
Hi Gilles

Bonjour Gilles, je te suggère de venir sur https://lazarus.developpez.com la communauté française pour Lazarus. Tu y trouvera de très bon tutoriel sur le langage pascal et sur l'utilisation de Lazarus. Et ce sera avec plaisir que nous t'aiderons. N'hésites donc pas à t'inscrire et poser toutes tes questions sur les forum dédiés au langage pascal et à lazarus entre autres

Cordialement

Jérôme

BeanzMaster

  • Sr. Member
  • ****
  • Posts: 268
Re: FileManager
« Reply #2 on: October 17, 2018, 04:17:50 pm »
Pour ce qui est de ton problème il faudrait en dire un peu plus, car il y existe plusieurs manières de lire un fichier. Comme http://wiki.freepascal.org/File_Handling_In_Pascal ou encore avec les "flux" https://www.freepascal.org/docs-html/rtl/classes/tstream.html ou bien encore tu peux passer pas un objet TStrings http://wiki.freepascal.org/TStringList-TStrings_Tutorial

A bientôt

Gilles

  • New Member
  • *
  • Posts: 37
Re: FileManager
« Reply #3 on: October 17, 2018, 04:53:46 pm »
AH merci, ça y est, je comprends l'anglais  :D

je développe en Pascal pur, sur XCode
Lazarus, c'est du orienté objet, et je n'ai jamais vraiment regardé comment ça marchait.
TurboPascal -> ThinkPascal -> CodeWarrior -> XCode with FPC -> (Well-deserved) Retirement (but not yet, not yet…)

Gilles

  • New Member
  • *
  • Posts: 37
Re: FileManager
« Reply #4 on: October 17, 2018, 06:02:10 pm »
TurboPascal -> ThinkPascal -> CodeWarrior -> XCode with FPC -> (Well-deserved) Retirement (but not yet, not yet…)

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: FileManager
« Reply #5 on: October 18, 2018, 03:32:59 am »
Bonjour Gilles, je te suggère de venir sur https://lazarus.developpez.com la communauté française pour Lazarus. Tu y trouvera de très bon tutoriel sur le langage pascal et sur l'utilisation de Lazarus. Et ce sera avec plaisir que nous t'aiderons. N'hésites donc pas à t'inscrire et poser toutes tes questions sur les forum dédiés au langage pascal et à lazarus entre autres.
Merci.

 

TinyPortal © 2005-2018