[Gambas-user] PVRec program (Rob)

Nelson Ferraz nferraz at ...184...
Wed Sep 3 16:47:29 CEST 2003


> PUBLIC FUNCTION GetNextDefaultFilename() AS String
>   DIM i AS Integer
>   i = 0
>   DO WHILE Exist(Application.home &/ "pvrusb" & i & ".mpg")
>     i = i + 1
>   LOOP
>   RETURN Application.home &/ "pvrusb" & Format(i, "000") & ".mpg"
> END
> 
> Hum, if 1'st file is saved as pvrusb000.mpg then DO WHILE can not find it,
> So the new one can be saved as pvrusb000.mpg.
> 
> I think a better job wil be: 
> DO WHILE Exist(Application.home &/ "pvrusb" & Format(i, "000") & ".mpg")

Suggestion:

DO WHILE Exist(DefaultFilename(i))
  i = i + 1
LOOP
RETURN DefaultFilename(i)

PRIVATE FUNCTION DefaultFilename(i as INTEGER) AS STRING
  RETURN Application.Home &/ "pvrusb" & Format(i, "000") & ".mpg"
END

(Just a cosmetic change :))

[]s

Nelson





More information about the User mailing list