Page 1 of 1

autoinc variable

Posted: Mon Nov 26, 2018 6:56 pm
by DieterG
Hello, it where very nice, if you implement autoincrement of variables,
To understand what i want.
This:

Code: Select all

		tdata_flen[segcount]=ByteAsc(temp$,0)		
		tdata_func[segcount]=MidStr(temp$,1,1,#ENCODING_RAW)		
		tdata_parlen1[segcount]=ByteAsc(temp$,2)			
		tdata_argtyp[segcount]=MidStr(temp$,3,1,#ENCODING_RAW)	
		tdata_flen[segcount]=ByteAsc(temp$,4)				
		tdata_typ1[segcount]=MidStr(temp$,5,1,#ENCODING_RAW)		
		tdata_arglen1[segcount]=ByteAsc(temp$,6)			
		tdata_arg1[segcount]=ByteAsc(temp$,7)			
	

should be better with:

Code: Select all

		i = 0
		tdata_flen[segcount]=ByteAsc(temp$,i+)		
		tdata_func[segcount]=MidStr(temp$,i+,1,#ENCODING_RAW)		
		tdata_parlen1[segcount]=ByteAsc(temp$,i+)	
		tdata_argtyp[segcount]=MidStr(temp$,i+,1,#ENCODING_RAW)	
		tdata_flen[segcount]=ByteAsc(temp$,i+)			
		tdata_typ1[segcount]=MidStr(temp$,i+,1,#ENCODING_RAW)	
		tdata_arglen1[segcount]=ByteAsc(temp$,i+)		
		tdata_arg1[segcount]=ByteAsc(temp$,i+)
	;here i should be 8				
Thanks for good work

Re: autoinc variable

Posted: Tue Nov 27, 2018 1:38 pm
by SamuraiCrow
What's wrong with an iterator function?

Code: Select all

Global iter
iter=-1 ;reset iterator
Function NextIter()
  iter=iter+1
  Return(iter)
EndFunction
...
		tdata_flen[segcount]=ByteAsc(temp$,NextIter())		
		tdata_func[segcount]=MidStr(temp$,NextIter(),1,#ENCODING_RAW)		
		tdata_parlen1[segcount]=ByteAsc(temp$,NextIter())
		tdata_argtyp[segcount]=MidStr(temp$,NextIter(),1,#ENCODING_RAW)	
		tdata_flen[segcount]=ByteAsc(temp$,NextIter())			
		tdata_typ1[segcount]=MidStr(temp$,NextIter(),1,#ENCODING_RAW)	
		tdata_arglen1[segcount]=ByteAsc(temp$,NextIter())	
		tdata_arg1[segcount]=ByteAsc(temp$,NextIter())
	;Here iter should be 7, the most recent value used.

Re: autoinc variable

Posted: Tue Nov 27, 2018 11:16 pm
by airsoftsoftwair
I agree that increment and decrement operators would be really nice to have, but it's not very likely because this is very complicated to hack into the VM.