[Implemented] FileSeek() »»» relative positions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

[Implemented] FileSeek() »»» relative positions

Post 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).
PB 4.30

Code: Select all

onErrorGoto(?Fred)
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

No opinions? :?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

not really.
quidquid Latine dictum sit altum videtur
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

lol Freak :lol:





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
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> lol Freak :lol:

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.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post 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? :o
PB 4.30

Code: Select all

onErrorGoto(?Fred)
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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...
quidquid Latine dictum sit altum videtur
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Hm... Okay, that's the first argumentation that REALLY convinced me :wink:

Macro => OK
Resident => Whaaat? :?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

AND51 wrote:Hm... Okay, that's the first argumentation that REALLY convinced me :wink:

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>
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.
Image
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I think it would be simpler to code and wonderfully concise if it were a new command in the form:

Code: Select all

FileMove(#file, number)
where number is negative if you want to go backwards. I vote that it's worth doing.
BERESHEIT
Dummy
Enthusiast
Enthusiast
Posts: 162
Joined: Wed Jun 09, 2004 11:10 am
Location: Germany
Contact:

Post by Dummy »

netmaestro wrote:I think it would be simpler to code and wonderfully concise if it were a new command in the form:

Code: Select all

FileMove(#file, number)
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.
Post Reply