Page 1 of 1
[Implemented] FileSeek() »»» relative positions
Posted: Wed May 02, 2007 6:14 pm
by AND51
Hello!
My idea is, that FileSeek() supports relative positons, e. g. "seek 1 char backwards, 2 chars forwad".
Then, you don't have to write FileSeek(#File, Loc(#File)-1) and so on.
Maybe, you can realize this with an extra-optional parameter, that specifies, if the 'NewPosition' is absolute or relative? Otherwise, you create a new command: FileSeekRelative(#File, NewRelativePosition).
Posted: Thu May 10, 2007 10:25 pm
by AND51
No opinions?

Posted: Thu May 10, 2007 11:25 pm
by freak
not really.
Posted: Fri May 11, 2007 5:28 am
by Dare
lol Freak
PS: Sounds like a nice extra. Maybe flagged?
FileSeek(#file,7,#BackWards)
FileSeek(#file,7,#ForeWards)
FileSeek(#file,7,#FromEnd)
FileSeek(#file,7,#FromStart) ; Default
Nice extra, but not an essential one.
First Linux, MacOS, oop (via a puredisphelper approach), 3D engine, etc.
Posted: Fri May 11, 2007 10:17 am
by PB
> lol Freak
Agreed.
AND51: You can do it with a variable, so I think that's why it won't be added.
Fred (or was it Freak?) has said the language won't have every little custom
command when the user is perfectly capable of doing something themselves.
Code: Select all
pos=Lof(0) : FileSeek(0,pos)
pos-9745 : FileSeek(0,pos)
pos+2571 : FileSeek(0,pos)
Posted: Fri May 11, 2007 1:18 pm
by AND51
> Maybe flagged?
as I said, an "extra-optional parameter" would be finde.
But your idea is exactly what I thought.
#FromEnd, nice idea!
PB wrote:AND51: You can do it with a variable, so I think that's why it won't be added.
Fred (or was it Freak?) has said the language won't have every little custom
command when the user is perfectly capable of doing something themselves.
I already said that I could do it in another way.
There are always better ways to do something. But is this a reason to not implement a nice feature? IMHO programing is fun. But only, if you can rely on PB. This flag could be optional, so ppl who want to use this, do it. Thos who find this bad, needn't to use this. I'm disappointed by those ppl who reject every new idea.
Perhaps, we can hear some more opinions or even Fred ones?

Posted: Fri May 11, 2007 1:43 pm
by freak
PB said it right. There is no need to add this, since all the functionality is there allready.
There is no need to add multiple ways to do the same thing.
Your proposal is not even shorter to type:
Code: Select all
FileSeek(#File, Loc(#File)-5)
FileSeek(#File, -5, #PB_File_Relative)
Just write a macro and put it in a resident, thats what they are good for...
Posted: Fri May 11, 2007 1:49 pm
by AND51
Hm... Okay, that's the first argumentation that REALLY convinced me
Macro => OK
Resident => Whaaat?

Posted: Fri May 11, 2007 1:56 pm
by ts-soft
AND51 wrote:Hm... Okay, that's the first argumentation that REALLY convinced me
Macro => OK
Resident => Whaaat?

Open Console:
Code: Select all
D:\Programmieren\PureBasic4\Compilers>pbcompiler /?
PBCompiler "FileName"
Options:
--------
/DEBUGGER: Enable the debugger
/EXE "FileName": Create an executable to the given filename
/DLL: Create a DLL
/CONSOLE: Create a console executable
/ICON "FileName": Add an icon to the executable
/RESOURCE "FileName": Add a resource file (.rc) to the executable
/QUIET: Disable all unnecessary textoutput
/COMMENTED: Produce a commented asm output (PureBasic.asm)
/REASM: Compile the 'PureBasic.asm' file to an executable
/XP: Add the Windows XP theme support to the executable
/INLINEASM: Enable the inline ASM support
/RESIDENT "FileName": Create a resident file to the given filename
/IGNORERESIDENT "FileName": ignore the given resident
/LINENUMBERING: Enable line numbering in the final executable for OnError
/STANDBY: Wait for external commands (editor, scripts...)
/MMX, /3DNOW, /SSE or /SSE2: Create a processor specific executable
/DYNAMICCPU: Create a executable containing all processor specific routines
/THREAD: Use thread safe runtime for strings and general routines
/UNICODE: Use unicode instead ascii for strings management
/SUBSYSTEM "Name": Use this subsystem to replace a set of internal functions
/VERSION: Display the version of the compiler
D:\Programmieren\PureBasic4\Compilers>pbcompiler test.pb /RESIDENT "test.res"
******************************************
PureBasic v4.02 (Windows - x86)
******************************************
Compiling test.pb
Loading external libraries...
Starting compilation...
Resident 'test.res' created.
D:\Programmieren\PureBasic4\Compilers>
Posted: Sat May 12, 2007 6:22 am
by netmaestro
I think it would be simpler to code and wonderfully concise if it were a new command in the form:
where number is negative if you want to go backwards. I vote that it's worth doing.
Posted: Sat May 12, 2007 11:56 pm
by Dummy
netmaestro wrote:I think it would be simpler to code and wonderfully concise if it were a new command in the form:
where number is negative if you want to go backwards. I vote that it's worth doing.
Code: Select all
Macro FileMove(file, value)
FileSeek(file, Loc(file)+value)
EndMacro
done.