ID:161246
 
how would I tell BYOND to read from an external text file at a specific line in the file?
proc/read_at_line(file, line)
var/text = file2text("[file]")

var/location = 1, counter = 1
while((++ counter) <= line) location = findtext(text, "\n", location + 1)

return copytext(text, location, findtext(text, "\n", location + 1))
In response to Popisfizzy
Popisfizzy wrote:
> proc/read_at_line(file, line)
> var/text = file2text("[file]")
>
> var/location = 1, counter = 1
> while((++ counter) <= line) location = findtext(text, "\n", location + 1)
>
> return copytext(text, location, findtext(text, "\n", location + 1))
>
>


That's pretty disappointing. Would have been better if BYOND could do it itself. Looks like a feature request.
In response to Obs
Obs wrote:
That's pretty disappointing.

No, it isn't.

Would have been better if BYOND could do it itself. Looks like a feature request.

No, it doesn't, heh. BYOND can't have every function you could want as a built-in feature, neither should it have much specialized procedures. That's what libraries are for, and we have those.
In response to Obs
I agree with you 100%.
DM doesn't have the basic file handling methods required for any simple file I/O.
Many times I've deferred the job to a separate script to make it easier, simple because DM doesn't have a nice file API.


In response to Crashed
Crashed wrote:
I agree with you 100%.
DM doesn't have the basic file handling methods required for any simple file I/O.

Right, it doesn't? Despite having the basic methods needed to softcode it? And newline parsing is a 'basic file handling method'? I really think Crashed needs to get his facts right before posting. =)

Many times I've deferred the job to a separate script to make it easier, simple because DM doesn't have a nice file API.

So let's make a built-in proc for every text-handling usage possible to solve the problem! Yeah!
In response to Kaioken
Kaioken wrote:
Obs wrote:
That's pretty disappointing.

No, it isn't.

Would have been better if BYOND could do it itself. Looks like a feature request.

No, it doesn't, heh. BYOND can't have every function you could want as a built-in feature, neither should it have much specialized procedures. That's what libraries are for, and we have those.


You have tragically missed the point. I don't care if BYOND has a thousand libraries for reading a file's specific line. That implementation IS very obvious.

The point is, we shouldn't have to write this in BYOND because fseek is a pretty common function that should be available as a proc. Having that function in machine code rather than having it interpreted would be a lot faster and would put less stress on the game.

In response to Obs
Obs wrote:
You have tragically missed the point.

Nope, I see your point, but you've missed mine.

Would have been better if BYOND could do it itself. Looks like a feature request.

-Everything- you'd do in DM code would be better if BYOND could do it itself internally. That doesn't mean the BYOND staff should waste time on including things you can already do as built-in procs. That's just an awful reason for a suggestion, and not your first specialized suggestion (I want to do -this- in -this- way in my game, so please include it in BYOND) either. New features should be added for things we can't do already, not the other way around.

I don't care if BYOND has a thousand libraries for reading a file's specific line. That implementation IS very obvious.

And that has nothing to do with the discussion here. Not to mention you're the one who made this topic. If you've been looking for a built-in function, you should have looked in the DM Reference instead, obviously.

The point is, we shouldn't have to write this in BYOND because fseek is a pretty common function that should be available as a proc.

Yeah, it is available in a proc. Write a custom proc. This is no different than many other programming languages. The whole universe isn't built-in into the language. Use a library or write your own. There are much more common functions than the "fseek" you're requesting here, if you're already talking about turning common functions into built-in.

Having that function in machine code rather than having it interpreted would be a lot faster and would put less stress on the game.

Again, that isn't different for any function you can make on BYOND, and such functionality is not nearly as common as other functions, either.
If you're so concerned about that speed, you shouldn't even use the BYOND platform. Write your own game in machine code (or write an external function in a DLL) rather than have the BYOND staff do it. There's no point in requesting every common function to be built-in just so you can have that speed boost. Frankly, what matters much more is designing your project efficiently, not the speed of every individual function.
In response to Kaioken
Kaioken wrote:
Obs wrote:
You have tragically missed the point.

Nope, I see your point, but you've missed mine.

Then what is my point.


Would have been better if BYOND could do it itself. Looks like a feature request.

-Everything- you'd do in DM code would be better if BYOND could do it itself internally. That doesn't mean the BYOND staff should waste time on including things you can already do as built-in procs. That's just an awful reason for a suggestion, and not your first specialized suggestion (I want to do -this- in -this- way in my game, so please include it in BYOND) either. New features should be added for things we can't do already, not the other way around.

A built-in Fseek is something that would benefit many games, not just my own.



I don't care if BYOND has a thousand libraries for reading a file's specific line. That implementation IS very obvious.

And that has nothing to do with the discussion here. Not to mention you're the one who made this topic. If you've been looking for a built-in function, you should have looked in the DM Reference instead, obviously.

I did look in the Reference, and I saw nothing about it. But the reference may be missing some information. There are numerous little "gotchas" about BYOND that I've learned along the way that aren't in the reference.


The point is, we shouldn't have to write this in BYOND because fseek is a pretty common function that should be available as a proc.

Yeah, it is available in a proc. Write a custom proc. This is no different than many other programming languages. The whole universe isn't built-in into the language. Use a library or write your own. There are much more common functions than the "fseek" you're requesting here, if you're already talking about turning common functions into built-in.

Again, if there was some way to write the function directly to machine code so BYOND wouldn't have waste time to interpret the basic Fseek function, I would. But I can't.


Having that function in machine code rather than having it interpreted would be a lot faster and would put less stress on the game.

Again, that isn't different for any function you can make on BYOND, and such functionality is not nearly as common as other functions, either.
If you're so concerned about that speed, you shouldn't even use the BYOND platform. Write your own game in machine code (or write an external function in a DLL) rather than have the BYOND staff do it. There's no point in requesting every common function to be built-in just so you can have that speed boost. Frankly, what matters much more is designing your project efficiently, not the speed of every individual function.

Kind of a total defeatist attitude, telling everyone to just leave BYOND, because they expect too much from it, never come back again. Is a man not entitled to the sweat of his own brow?
In response to Obs
You didn't just quote Bioshock, did you?
In response to Popisfizzy
</thread>
In response to Obs
Yes, it was completely off-topic, but I was distracted from that by the incredibly gap between the my jaw and the top of my mouth.
In response to Obs
Obs wrote:
Then what is my point.

Obviously enough, it is "I want function X to be built-in in BYOND, because while I can write it myself, it is too slow for my taste that way".

Would have been better if BYOND could do it itself. Looks like a feature request.

-Everything- you'd do in DM code would be better if BYOND could do it itself internally. That doesn't mean the BYOND staff should waste time on including things you can already do as built-in procs. That's just an awful reason for a suggestion, and not your first specialized suggestion (I want to do -this- in -this- way in my game, so please include it in BYOND) either. New features should be added for things we can't do already, not the other way around.

A built-in Fseek is something that would benefit many games, not just my own.

Way to ignore the rest of the paragraph you've quoted. What's the point of discussion if you do that? Since there's no point to copying what I said once more, I won't.

I did look in the Reference, and I saw nothing about it. But the reference may be missing some information. There are numerous little "gotchas" about BYOND that I've learned along the way that aren't in the reference.

While it's true that the DM Reference doesn't have everything about DM in it, it does have almost all procs there. A text handling proc like this wouldn't be excluded from it, like findtext() isn't, for example.
Just saying, it should be safe to assume a built-in proc doesn't exist if you didn't see it in the Reference and the forum (by a quick search). I've found more "gotcha"s by reading the whole Reference once than reading lots and lots of forum posts or other things along the way.

Again, if there was some way to write the function directly to machine code so BYOND wouldn't have waste time to interpret the basic Fseek function, I would. But I can't.

I'm not saying you should scram off the community and never use BYOND like you've assumed or something like that: but in DM you're writing 'DM code', compiled into bytecode. If you want to write things that can be compiled into machine code because you're dissatisfied with the efficiency of bytecode for example, you should probably use something that suits you better, no?

Again, if there was some way to write the function directly to machine code

Why, of recently, you actually can, like I said before. Write it (in another language of course), compile into a DLL and use the call() procedure.

Kind of a total defeatist attitude, telling everyone to just leave BYOND, because they expect too much from it, never come back again.

What I'm saying is simple. If you're so concerned about the time it takes procedures to run in DM, it would be in your interest to use a different language than DM. Bytecode is slower by nature. It would be faster as well because you wouldn't need to wait for the BYOND staff to hardcode functions for you.

Is a man not entitled to the sweat of his own brow?

Is your name Andrew Ryan?
In response to Kaioken
Look man, it wouldn't be the first time a function was written for BYOND by the devs that could have been done in DM script.
In response to Kaioken
Kaioken wrote:
Obviously enough, it is "I want function X to be built-in in BYOND, because while I can write it myself, it is too slow for my taste that way".

I don't see the issue. Last time I checked, you aren't BYOND Staff. Why are you bashing his idea?

-Everything- you'd do in DM code would be better if BYOND could do it itself internally. That doesn't mean the BYOND staff should waste time on including things you can already do as built-in procs. That's just an awful reason for a suggestion, and not your first specialized suggestion (I want to do -this- in -this- way in my game, so please include it in BYOND) either. New features should be added for things we can't do already, not the other way around.

That would be like saying "Well, because we already have copytext(), there is no need for findtext() to be implemented into BYOND because the goal of findtext() can already be reached through soft-coded methods." I'd HATE if findtext() weren't built right in.
In response to Obs
Neither would be the opposite. But if you can already do it fine, "it's a little slower" isn't a good enough reason.
In response to CaptFalcon33035
CaptFalcon33035 wrote:
I don't see the issue. Last time I checked, you aren't BYOND Staff. Why are you bashing his idea?

So, I have to be the BYOND Staff to post my opinion on something and express myself? I don't see the issue here.
Why are you bashing my bashing of his idea? You aren't a moderator, last I checked.

I don't see the point of what you said here. You should be smart enough to know forums are for public discussion.

That would be like saying "Well, because we already have copytext(), there is no need for findtext() to be implemented into BYOND because the goal of findtext() can already be reached through soft-coded methods."

It isn't, because findtext() has a general and basic purpose which is often needed. Parsing a specific character isn't as such, which is why we have findtext() and copytext() so we can do all kinds of things, not only parse newlines.
In response to Kaioken
BYOND is doomed to a fate of never being taken seriously.
In response to Kaioken
Kaioken wrote:
So, I have to be the BYOND Staff to post my opinion on something and express myself? I don't see the issue here.
Why are you bashing my bashing of his idea? You aren't a moderator, last I checked.

I don't see the point of what you said here. You should be smart enough to know forums are for public discussion.

What you're doing is saying "No, this isn't going to happen. This idea isn't worthy. My opinion is better than yours."

It isn't, because findtext() has a general and basic purpose which is often needed. Parsing a specific character isn't as such, which is why we have findtext() and copytext() so we can do all kinds of things, not only parse newlines.

And fseek is not often needed? Who is to say what's often needed and what isn't? How are you going to determine that it is not needed often enough? Perhaps people have strayed away from doing such a procedure themselves because the processing cost is enormous for larger files and sacrificed convenience for importance. You don't know.
In response to CaptFalcon33035
CaptFalcon33035 wrote:
What you're doing is saying "No, this isn't going to happen.

No, I'm not saying this. That isn't my decision, and doesn't depend on me. I am however, saying that in my opinion, it is not a good enough suggestion.

This idea isn't worthy.

Indeed, this is what I'm saying.

My opinion is better than yours."

Sure, while it isn't the main objective of my post to prove, in effect, this could be said about everyone who participates in an argument or otherwise attempts to correct another, including you. Nothing's really wrong with it.

And fseek is not often needed?

No, it isn't needed 'very often', or in the majority of games. It isn't as important and often needed as findtext() for example, also because it is specialized and intended for a specific purpose, unlike findtext(). It isn't fundamental, so it shouldn't be included as one.

Who is to say what's often needed and what isn't?

Whoever makes games/projects, plays games (and has the possibility ability to discern such things from playing), and more.

How are you going to determine that it is not needed often enough?

Obviously from my personal experience and that of others (that I have observed).

Perhaps people have strayed away from doing such a procedure themselves because the processing cost is enormous for larger files and sacrificed convenience for importance. You don't know.

Perhaps. Perhaps not. But if this is really the only reason for such a suggestion, it is quite biased since you could say this for pretty much every function, yet you only request one for this reason, with no other argument why it should be implemented. There are more important functions to implement, including things you cannot do yet.

And again, what I'm saying here is my opinion. It is naturally not necessarily the opinion of the BYOND Staff(tm) and neither opinions here are necessarily right.
Page: 1 2