TIP: Click on subject to list as thread! ANSI
echo: qedit
to: ALL
from: DAVID MARCUS
date: 1997-06-26 06:53:00
subject: Re: SAL programming

From: DavidMarcus@MindSpring.com (David Marcus)
James C. Sewell wrote on Wed, 25 Jun 1997 15:40:04 -0400:
>Open to suggestions...
These macros create an array (self-sizing upon writes) and write and read. 
he
array is actually a temp buffer indexed by line number.  Note - this is off
the top of my head - may need edit before compile.
integer proc CreateArray()
	integer rc
	PushPosition()
	if not CreateTempBuffer()
		KillPosition()
		return(FALSE)
	else
		rc = GetbufferID()
		PopPosition()
		return(rc)
	endif
end
integer proc WriteIntegerToArray(INTEGER value_to_write, INTEGER,
array_position, INTEGER array_bufferID)
	PushPosition()
	if not gotoBufferID(array_bufferID)
		KillPosition()
		return(FALSE)
	endif
	while array_position() > numLines()
		EndFile()
		AddLine()
	endwhile
	GotoLine(array_position)
	DelToEOL()
	InsertText(Str(value_to_write), _INSERT_)
	PopPosition()
	return(TRUE)
end		
integer proc WriteStringToArray(STRING string_to_write, INTEGER,
array_position, INTEGER array_bufferID)
	PushPosition()
	if not gotoBufferID(array_bufferID)
		KillPosition()
		return(FALSE)
	endif
	while array_position() > numLines()
		EndFile()
		AddLine()
	endwhile
	GotoLine(array_position)
	DelToEOL()
	InsertText(string_to_write, _INSERT_)
	PopPosition()
	return(TRUE)
end		
integer proc ReadIntegerFromArray(INTEGER array_position, INTEGER
array_bufferID)
	integer rc
	// return MAXINT if no array or position greater than size or array
	// return MININT if position not initialized
	PushPosition()
	if not gotoBufferID(array_bufferID) 
	   or not GotoLine(array_position)
		KillPosition()
		return(MAXINT)
	endif
	if CurrLineLen() = 0
		PopPosition()
		return(MININT)
	else
		rc = val(GetText(1,CurrLineLin()))
		PopPosition()
		return(rc)
	endif
end
string proc ReadStringFromArray(INTEGER array_position, INTEGER
array_bufferID)
	string rc[255] // set to largest possible string
	// return str(MAXINT) if no array or position greater than size of array
	PushPosition()
	if not gotoBufferID(array_bufferID) 
	   or not GotoLine(array_position)
		KillPosition()
		return(str(MAXINT))
	endif
	RSFArc = GetText(1,CurrLineLin()))
	PopPosition()
	return(rc)
end
============================================
David R. Marcus - Documentation Manager
IQ Software Corporation (www.iqsoftware.com)
davidm@iqsc.com   DavidMarcus@MindSpring.com
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.