maybe, to early in the morning for an unemployed to discuss technical stuff in another language.
using #pb_any
I like this better, personally:
I hope PB gets this syntax one day 
Code: Select all
if (file = fopen("test.txt","rb")) {
// etc
}
It would be nice if the library functions raised errors as well as returning values. For example, the helpfile states for SetErrorNumber():
Why can't the OpenFile function just raise error number 53 for us, so that we can catch it that way?You can forcibly fire an error. For example if you did not find a file, fire an error number 53 and let the error handler show the error for you.
Re: using #pb_any
What you want is impossible, because in PB (and all Basics) compare (is eqal) and "set" is the same char (=).MLK wrote:just want to say...
i like this more:then:Code: Select all
If CreateFile(#file=#PB_Any,file$) DeleteFile(file$) EndIfCode: Select all
If #file=CreateFile(#PB_Any,file$) DeleteFile(file$) EndIf
And so you can't set a variable in a If-Statement.
btw: you can't delete a open file...
Code: Select all
Procedure CreateFileX(*Handle.LONG,File$)
*Handle\l=CreateFile(#PB_Any,File$)
ProcedureReturn *Handle\l
EndProcedure
If CreateFileX(@GetNb,"C:\Test.txt")
CloseFile(GetNb)
EndIfWhat is the purpose of #PB_Any?
Yeah, the topic suddenly got very obscure, what with the introduction of #PB_Any and mention of an "old" and "New"" way of assigning handles.
So where does #PB_Any come into play? I can't find any reference to it.
One of the problems here is the way in which "=" is being used. The purpose of "=" is to either assign a new value to the left hand variable, or to determine whether two items are equal in value without changing either.
The syntax gets ugly when it is not clear which use the programmer intended, or what action the compiler will actually take. In this case, the "ugly" means ambigious or uncertain.
Some languages require you to use "==" in place of "=" when you mean to compare two quantities or items, but this can be a problem when the programmer forgets this and only uses "=", which then produces the wrong outcome.
So, with regards to the previous discussion, the preferred method would be to assign the handle to a variable, then determine if the variable held a non-zero value, meaning that the act of creating or opening the file had been successful. That is straightforward and simple, and non-ambigious.
So where does #PB_Any come into play? I can't find any reference to it.
One of the problems here is the way in which "=" is being used. The purpose of "=" is to either assign a new value to the left hand variable, or to determine whether two items are equal in value without changing either.
The syntax gets ugly when it is not clear which use the programmer intended, or what action the compiler will actually take. In this case, the "ugly" means ambigious or uncertain.
Some languages require you to use "==" in place of "=" when you mean to compare two quantities or items, but this can be a problem when the programmer forgets this and only uses "=", which then produces the wrong outcome.
So, with regards to the previous discussion, the preferred method would be to assign the handle to a variable, then determine if the variable held a non-zero value, meaning that the act of creating or opening the file had been successful. That is straightforward and simple, and non-ambigious.
has-been wanna-be (You may not agree with what I say, but it will make you think).



