Question:
I am a rookie at PowerBuilder. I use PB 5, and I can’t seem to find a function that reads a specific number of chars from a file into a string. I saw that I can read the whole file into a string, but suppose I want to read five characters from the file. How can I do it? Is it even possible?
Answer:
PowerBuilder’s file functions are stream- and line-based. Your only options are to read in a single line (terminated by ~r~n) from a file or up to a maximum of 32,767 characters to the end of the file.
With these two simple functions you can achieve most tasks. If you want the first five characters, then you can use either of the above methods to read in a chunk of data and then just use the Left function to get the characters you want.