Embarassing fundamental question

General support topics
Post Reply
wspillma
Posts: 1
Joined: Tue Dec 08, 2020 6:36 pm

Embarassing fundamental question

Post by wspillma » Tue Dec 08, 2020 7:05 pm

I am an experienced programmer, and have used various forms of Basic in the past. BestBASIC seems to be the only game in town now and I was excited to find it, and I bought it via the Apple App Store for my iMac. The first thing I wanted to try was to put a text file Input.txt into the files section of the app. Input.text would be of the form

N 'number of data pairs
x1,y1 'first data pair
.
.
.
xN,yN 'Nth data pair

I want to write some code that would load the numerical values N and the x(i),y(i) data pairs into BestBasic. Then I wanted to create a file called Output.txt and write N and the x(i),y(i) pairs to it. I should have no trouble operating on the data when I need to, but I feel pretty stupid not being able to figure out how to do basic input/output. I was hoping for something simple like the old Basic file handling structure, i.e. something like: Open "c:\filename.tst" For Input As 3. If someone could just supply me with some sample code to do what I have stated above, I would really appreciate it and would be off and running. Thanks for indulging me.

User avatar
kibernetik
Site Admin
Posts: 146
Joined: Tue Aug 06, 2019 3:03 pm

Re: Embarassing fundamental question

Post by kibernetik » Tue Dec 08, 2020 11:52 pm

There is a "Files" section in Documentation which describes files reading/writing functions.

There is an example program "Miscellaneous/words counter.txt" which counts words in a text files and prints some statistics.

Also you can read more information about files functions in a book https://bestbasic.net/site/documentation.html.

Post Reply