autoinc variable

Feature requests for future versions of Hollywood can be voiced here
Post Reply
DieterG
Posts: 20
Joined: Tue Oct 23, 2018 9:40 pm

autoinc variable

Post by DieterG » Mon Nov 26, 2018 6:56 pm

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
Dieter

SamuraiCrow
Posts: 222
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: autoinc variable

Post by SamuraiCrow » Tue Nov 27, 2018 1:38 pm

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.

User avatar
airsoftsoftwair
Posts: 3113
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: autoinc variable

Post by airsoftsoftwair » Tue Nov 27, 2018 11:16 pm

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.

Post Reply