[Implemented] FileSeek() »»» relative positions
[Implemented] FileSeek() »»» relative positions
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).
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).
PB 4.30
Code: Select all
onErrorGoto(?Fred)
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.

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.
Dare2 cut down to size
> 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.

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)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
> Maybe flagged?
as I said, an "extra-optional parameter" would be finde.
But your idea is exactly what I thought.
#FromEnd, nice idea!
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?
as I said, an "extra-optional parameter" would be finde.
But your idea is exactly what I thought.
#FromEnd, nice idea!
I already said that I could do it in another way.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.
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?

PB 4.30
Code: Select all
onErrorGoto(?Fred)
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:
Just write a macro and put it in a resident, thats what they are good for...
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)
quidquid Latine dictum sit altum videtur
Hm... Okay, that's the first argumentation that REALLY convinced me
Macro => OK
Resident => Whaaat?

Macro => OK
Resident => Whaaat?

PB 4.30
Code: Select all
onErrorGoto(?Fred)
Open Console:AND51 wrote:Hm... Okay, that's the first argumentation that REALLY convinced me![]()
Macro => OK
Resident => Whaaat?
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>
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
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
FileMove(#file, number)
BERESHEIT
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
FileMove(#file, number)
Code: Select all
Macro FileMove(file, value)
FileSeek(file, Loc(file)+value)
EndMacro