15

A number of early microcomputer BASICs had 'array like strings' that were unlike MS's system and instead behaved like arrays of char. Substrings were accessed using a syntax like:

A$ = B$(1,5)

as opposed to the MS style:

A$ = LEFT$(B$,4)

Note the potential off-by-one.

I know that some minicomputer BASICs also worked this way, I believe HP and Nova were the canonical examples. North Star BASIC also used this style, and I suspect, due to its origins, that Cromenco Extended BASIC did as well.

So the question: does anyone know the first microcomputer BASIC that used this style of string notation? And wider, where this style originated?

7
  • 2
    Why and how are you distinguishing micros from minis? A given BASIC could be made to run on either. Commented May 8, 2019 at 11:32
  • 1
    HT2000 Basic worked as described; any microcomputer BASICs probably derived such behavior from the HP.
    – supercat
    Commented May 8, 2019 at 11:46
  • 3
    For reference, both approaches seem to be revisionist treatments :-). BASIC comes from Dartmouth. 4th edition BASIC had the CHANGE statement to convert between a string variable and an array of ASCII character-codes..
    – dave
    Commented May 8, 2019 at 12:01
  • I do however think I used the LEFT$/RIGHT$ syntax around 1971, dialed in to the UK Open University computer system (I had a maths teacher doing an OU degree in computer science), which I think was running on some HP mini.
    – dave
    Commented May 8, 2019 at 12:06
  • @another-dave I don’t know much about minis, but LEFT$ seems to have appeared on micros early on; 8K Altair BASIC had it in 1975. Commented May 8, 2019 at 12:17

3 Answers 3

16

I think the earliest BASIC dialects on micros to use these constructs for strings were North Star BASIC and Apple Integer BASIC in 1977, both presumably influenced by HP BASIC. The Apple lineage isn’t surprising since Steve Wozniak worked at HP.

The origin of this approach to substring addressing could be FORTRAN, which uses a syntax of the form A(I:L).

4
  • Apple BASIC used this style? I didn't know that! Commented May 8, 2019 at 12:56
  • 2
    Only Apple integer basic, Applesoft was standard MS Left/Right/Mid
    – PeterI
    Commented May 8, 2019 at 13:04
  • Cromenco also did, but that's 1978. So its looking like NS BASIC might be it. What about the Tiny derivatives, did any of them have strings? Commented May 8, 2019 at 14:35
  • @Maury Tiny BASIC had string literals for PRINT; MINOL added a way to store strings and retrieve them, using pointers only (no string variables), but didn’t support sub-strings. I don’t know of any other Tiny derivative which had string variables with something like A$(2,4) before NS BASIC. Commented May 8, 2019 at 15:23
5

Sinclair's Basic used the slicing syntax for string manipulation. It even uses it as lvalue. It is imho very clever as it allows some operations without generating lot of garbage as the Microsoft way does. For example: replacing 2 character in the middle of a string

Sinclair syntax:

 LET A$="123456789"
 LET A$(4 TO 5)="ab"
 PRINT A$

 123ab6789

Microsoft syntax:

 A$="123456789"
 A$=LEFT$(A$,4)+"ab"+MID$(A$,6): REM Only if Basic support 2 parameters MID$
 ?A$

 1234ab789   (but internally 4 temporaries were created "123456789","1234","ab" and "789".

(MS example might be off by 1)

4
  • 1
    At least in the 48k BASIC, string slicing involves the TO keyword. It's something like A$(10 TO 20). But I can't remember exactly. It's been a while. Commented Jul 7, 2020 at 8:47
  • @OmarL - just tried it and your memory of the syntax is correct, at least for the Spectrum version. (Have edited the example given to be correct as just verified)
    – occipita
    Commented Jul 7, 2020 at 10:46
  • Thank you guys. It was my bad. Too much programming in D and I discovered the sinclair basic slicing only recently. Commented Jul 7, 2020 at 12:57
  • Yep, the ZX BASIC string slicing was much better than the LEFT$/RIGHT$/MID$ burden in other BASICs, including the otherwise-elegant BBC BASIC. a$(TO 5) is the left 5 characters, a$(7 TO) is the everything from the 7th character onwards. Simple.
    – TonyM
    Commented Jul 7, 2020 at 14:14
0

Follow up: following the leads above, and having burrowed into the rabbit hole much deeper than intended, I think it's safe to say the ultimate answer is Integer BASIC.

Woz's dialect is (of course) well documented and directly states it was ported from HP. It dates to early 1976, when he started visiting the Homebrew meetings to demonstrate it. I suppose one could mark its "official" release to July 1976 when the Apple I was first put on sale.

The other early possibility is SCELBAL, which was first detailed in February 1976 and shipped in book form a few months later. However, this initial version did not include string support, and the Strings Supplement which added that code is copyrighted to 1977. I strongly suspect it took it string functions from Integer, not HP directly, although I will check with the author on that one.

4
  • Then again, the restriction to 'micro' is an arbitrary when it comes to High Level Languages. After all, they are meant to not be (as) hardware dependent. (Say, were to put an Olivetti P6060?)
    – Raffzahn
    Commented Jul 6, 2020 at 14:27
  • But fails the main razor for the post: P6060 BASIC does not appear to use slicing and is based on Dartmouth's CONVERT. Commented Jul 6, 2020 at 15:58
  • 1
    For what's it worth, P6060 BASIC used EXT$ (extract from-to) and REP$ (replace), and no CHANGE command. So it's a third variant. P6060 BASIC had the MAT operations and other Dartmouth features, though.
    – dirkt
    Commented Jul 6, 2020 at 18:05
  • @MauryMarkowitz The P6060 wasn't mentioned for that feature, but to prove the micro argument. After all, micro has been used rather loosely before the 1980s - which is were you're question takes place, isn't it?
    – Raffzahn
    Commented Jul 6, 2020 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .