TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: KURT KUZBA
from: MIKE LUTHER
date: 1998-02-04 04:40:00
subject: Re: Help with multi-dim chara

Hi ^2 Kurt! 
 
OBASIC handled it - roughly - this way..  They consider that where a fixed 
amount of memory must be declared and reserved as a global for the entire run 
of the program, it may be coded as ONE array of K$ for the ENTIRE array space 
of that variable!  Then, they auto-coded the routines so that the old 
"array" was passed as one long character array, the pointer to which can be 
passed in either MAIN or a FUNCTION.  At that time, each segment of 
characters can be read from a disk file, however one reads it, then plugged 
into the segment in linear memory that corresponds to the n'th element of 
K$() in the old world of Basic. 
 
The OBASIC routine for about 21 lines of code in BASIC, expanded to about 325 
lines of "C" to get the equivalent operation..  :) 
 
Of course, we are shielded from such trivialities in BASIC by the fact that 
is all buried in the libraries...  chuckle. 
 
Their "solution" to roughly: 
 
 DIM K$(100) AS STRING * 256 
 
 GOSUB mydeal 
 PRINT K$(2) 
 PRINT K$(4) 
 END 
 
 mydeal 
 
   FOR NZ = 1 TO 99 
     INPUT #3, K$(NZ) 
   NEXT NZ 
 
 RETURN 
 
turns out to be: 
 
 
 /*Compiler Declaration and Variable Section*/ 
 
 /*User Declaration and Variable Section*/ 
 
 /*Temporary Vector*/ 
 
 static _vector _TmpVec1; 
 
 /* LN:4  DIM K$(100) AS STRING * 256 */ 
 static unsigned char K_Str[25600]; 
 void mydeal(); 
 
 ...... 
 
 /*Code Section*/ 
 
 ....... 
 
 /* LN:6  GOSUB mydeal */ 
 
 mydeal(); 
 
 /* LN:7  PRINT K$(2) */ 
 _PrtPthNum=1; 
 _a0=K_Str; 
 _d0=0x2; 
 _d0--; 
 _d0=_d0*256; 
 (long)_a0=(long)_a0+_d0; 
 _TmpVec1._Ptr=_a0; 
 _TmpVec1._Len=256; 
 _TmpVec1._Lnk=0; 
 _PrintStr(&_TmpVec1,_BufSize); 
 if (STATUS == -1) longjmp(_ebuf,1); 
 XferCount=STATUS; 
 _XferAddr=_CRLF; 
 XferCount=2; 
 STATUS=write(_PrtPthNum,_XferAddr,XferCount); 
 if (STATUS == -1) longjmp(_ebuf,1); 
 XferCount=STATUS; 
 POS=0; 
 
 /* LN:8  PRINT K$(4) */ 
 _PrtPthNum=1; 
 _a0=K_Str; 
 _d0=0x4; 
 _d0--; 
 _d0=_d0*256; 
 (long)_a0=(long)_a0+_d0; 
 _TmpVec1._Ptr=_a0; 
 _TmpVec1._Len=256; 
 _TmpVec1._Lnk=0; 
 _ PrintStr(&_TmpVec1,_BufSize); 
 if (STATUS == -1) longjmp(_ebuf,1); 
 XferCount=STATUS; 
 _XferAddr=_CRLF; 
 XferCount=2; 
 STATUS=write(_PrtPthNum,_XferAddr,XferCount); 
 if (STATUS == -1) longjmp(_ebuf,1); 
 XferCount=STATUS; 
 POS=0; 
 
 /* LN:9  END  */ 
 exit(0); 
 
 /*Function and Subroutine Section*/ 
 
 void mydeal() 
 { 
 
 /*Pseudo Registers*/ 
 register long _d0; 
 register long _d1; 
 double _d0f; 
 double _d1f; 
 register void *_a0; 
 
 /* LN:17    FOR NZ = 1 TO 99 */ 
 NZ=0x1; 
 _Lbl1:; 
 if (NZ>0x63) goto _Lbl3; 
 
 /* LN:18      INPUT #3, K$(NZ) */ 
 _d0=0x3; 
 _d0=_d0&0xff; 
 _IOPthNum=_d0; 
 STATUS=write(1,&_Prompt,1); 
 if (STATUS == -1) longjmp(_ebuf,1); 
 _a0=K_Str; 
 _d0=NZ; 
 _d0--; 
 _d0=_d0*256; 
 (long)_a0=(long)_a0+_d0; 
 _TmpVec1._Ptr=_a0; 
 _TmpVec1._Len=256; 
 _TmpVec1._Lnk=0; 
 _InpData(&_TmpVec1,6,_BufSize); 
 if (STATUS == -1) longjmp(_ebuf,1); 
 XferCount=STATUS; 
 
 /* LN:19      NEXT NZ */ 
 _Lbl2:; 
 NZ++; 
 goto _Lbl1; 
 _Lbl3:; 
 /* LN:20    CLOSE #3 */ 
 errno=0; 
 _d0=0x3; 
 _d0=_d0&0xff; 
 _IOPthNum=_d0; 
 STATUS=close(_IOPthNum); 
 if (STATUS == -1) longjmp(_ebuf,1); 
 /* LN:21  RETURN      */ 
 return ; 
 } 
 
Choices.... choices..... :) 
 
But then, I guess that mos' folks haven't looked at what the PRINTF function 
really looks like inside... :( 
 
Mike @ 117/3001 
--- Opus-CBCS 1.73a
---------------
* Origin: Ziplog Public Port (1:117/3001.0)

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™.