Read() as a procedure

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
PB&J Lover
Enthusiast
Enthusiast
Posts: 212
Joined: Fri Apr 22, 2005 2:07 pm
Location: U.S.A.
Contact:

Read() as a procedure

Post by PB&J Lover »

In keeping with the PB language format of Result = Procedure(arguments) you really need to make READ() a procedure.

That would allow:

Code: Select all

restore MyData

IF FindString(Read(),".",1)

do something.

EndIf
This way data can be directly piped into some process.

In fact it would be good to go: Result = READ(MyData1) where "MyData is the DATA section. That way you could nest READ statements that reference different DATA section in the same line.

Thanks.
-- DB

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage — to move in the opposite direction.

Albert Einstein
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

You could do it yourself...

Code: Select all

Procedure.s ReadS()
	Read result$
	ProcedureReturn result$
EndProcedure

Procedure ReadI()
	Read result
	ProcedureReturn result
EndProcedure

Procedure.f ReadF()
	Read result.f
	ProcedureReturn result
EndProcedure

If OpenConsole()
	PrintN("Using procedure read")
	
	Restore TextData
	For n=1 To 3
		PrintN(ReadS())
	Next
	
	PrintN("Press return to exit")
	Input()
	CloseConsole()
EndIf
End

DataSection
TextData:	Data$	"This is a test","Another test","Test #3"
EndDataSection
The above code could easily be made into a library.

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

That's right, 'Read' is a bit an oddity as it's coming from the old Basic langages which had such behaviour..
Post Reply