Tenaja wrote:
No, read.s is not a workaround, but is not a "function" that allows assigning a var its return value. But is IS cumbersome coding because it requires a "temporary" variable.
I gather that you are requesting a function that modifies the data pointer and returns a type of data read from the data pointer. I agree that that would be a useful thing.
Contrary to your comment you currently can use 'Read' to place data directly in a variable without the need for a temporary variable, you just can't use it in an any kind of expression or as a literal (without being placed in a variable). You would just use: Read.s MyString.
As stated PeekS() and it's relatives are functions and return data of a specific type but do not update a data pointer. I suggest that instead of adding a group of new 'Read' functions that a 'Peek' type of function be implemented that updates a data pointer.
Perhaps something like IPeekS(*dataPtr), IPeekD(*dataPtr), and etc. The 'I' stands for increment. It would return the data from the memory location and update the pointer by the size of the data.
It would look something like:
Code:
;here are two stand-in macros representing the functionality desired
Macro IPeekB(ptr)
PeekB(ptr): ptr + SizeOf(Byte)
EndMacro
;a version that handles the specification of length or flags is desired but is not shown here
Macro IPeekS(ptr)
PeekS(ptr): ptr + (MemoryStringLength(ptr) + 1) * SizeOf(Character)
EndMacro
DataSection
stuff:
Data.b 5
Data.s "first", "second", "third", "fourth", "fifth"
EndDataSection
*dataPtr = ?stuff
count = IPeekB(*dataPtr) ;pointer will be incremented by 1 for the size of a byte
For i = 1 To count
Debug IPeekS(*dataPtr) ;pointer will be incremented by the memory length of the string + Null
Next
I think such a think would be useful because it would complement the 'Read' functionality with direct access to memory. As a plus it would allow several simultaneous reads from different locations.
If implemented it would also would beg the question, "Neglecting the origins of BASIC, why would you need 'Read' for anything anymore?"
It should be noted that the current function of Data/Read does not allow the use of fixed length strings.
@Edit: corrected typo from "just can use" to "just can't use"