# Create array from phrase using Pascal



## gpatrick (Aug 12, 2013)

In the shell one can do:

```
print -n "Enter volume groups: "
read vg_args
set -A VG $(echo ${vg_args[@]})
numVG=${#VG[@]}
```

How is that accomplished in Pascal?


----------



## SirDice (Aug 12, 2013)

Pascal? Seriously? Is there still somebody _who_ uses that? I mean it was already out of fashion when I was in school. And that was 20+ years ago :q


----------



## fonz (Aug 12, 2013)

SirDice said:
			
		

> Is there still somebody who uses that?


Pascal is still widely used as a source language in teaching compiler building (although admittedly that probably isn't particularly relevant in this case). And if my memory serves me well, variants of Pascal are still used in the Delphi world.


----------



## fonz (Aug 12, 2013)

gpatrick said:
			
		

> How is that accomplished in Pascal?


I imagine that one way to do this would be to make one pass over the input string in order to count how many words there are, then allocate an array with that many elements and finally making a second pass over the input string to copy the words into the array you just allocated. Is it pretty? No. But it's the only thing I can think of right now and admittedly my Pascal is rather rusty.


----------



## kpa (Aug 12, 2013)

fonz said:
			
		

> Pascal is still widely used as a source language in teaching compiler building (although admittedly that probably isn't particularly relevant in this case). And if my memory serves me well, variants of Pascal are still used in the Delphi world.



It was used in teaching when I was in the university studying compilers and formal languages around 1997-1998. It has been replaced with Java now. The other language that seems to be used is Python.


----------



## expl (Aug 12, 2013)

SirDice said:
			
		

> Pascal? Seriously? Is there still somebody _who_ uses that? I mean it was already out of fashion when I was in school. And that was 20+ years ago :q



The Windows Skype client UI is written in Objective Pascal.


----------



## fonz (Aug 12, 2013)

kpa said:
			
		

> It was used in teaching when I was in the university studying compilers and formal languages around 1997-1998.


Same here, although maybe five years or so later.



			
				kpa said:
			
		

> It has been replaced with Java now. The other language that seems to be used is Python.


Rest assured plenty of compiler building courses nowadays still use Pascal. And given how well-structured it is, I can't say it surprises me. But yes, Python is also a good choice and probably more interesting for students because it's a language that is actively being used today. But I digress...


----------

