As_variable()

Converts a string into an internal Open GENIE variable type.

AS_VARIABLE astring=String Read a string into a variable

example:

	# Obtain a number from an awkward string
	>> printn w.title
	BaCuO2 Sprogget & Sylvester t=.589E+1K
	>> tstr = Substring(w.title, locate(w.title,"=")+1)
	>> printn as_variable(tstr)
	5.89

Note: Only reads valid numbers otherwise returns the string.

As_variable

This function is used in much the same way as the FORTRAN internal read statement. It allows a GCL program to get a real or integer value from a string. Normally for user input this is done automatically by the Inquire() command but there may be situations where, as in the example above a number already comes as a string type.

The As_variable() command will attempt to return either a real or integer depending on whether a decimal point is in evidence. If the string passed to the command starts with something which cannot be a number, the original string is returned. It is assumed that, as in the example above, the numeric part of the string is being passed. There is no need to trim the end of the string (unless it makes the number ambiguous) as any extra text will be discarded.

Parameters:

Astring (String)

A string which starts with the number to be read. Any white space in front of the number will be ignored.

RESULT = (Real, Integer or String)

Either a String, Integer or Real depending on whether the function was able to decode a number.