Oxygen Basic
		Programming => Bugs & Feature Requests => Topic started by: Brian Alvarez on August 19, 2019, 07:17:04 PM
		
			
			- 
				Other variables can be declared in the same row, just by separating them with a comma, 
 not pointers. Pointers wont work when declaring them that way... even worse, they fail silently.
 
 Also, you can use chr() with a byte pointer variable alone, but if you append more numbers
 the function gets broken.
 
     string s1 = "A"
 string s2 = "B"
 string s3 = "C"
 
 byte ptr p1
 byte ptr p2, p3  ' p3 pointer is broken.
 
 @p1 = StrPtr(s1)
 @p2 = StrPtr(s2)
 @p3 = StrPtr(s3)
 
 print chr(p1) chr(13, 10)
 print chr(p2) chr(13, 10)
 print chr(p3) chr(13, 10)
 
 ' print chr(p1, 13, 10) ' Compilation time error.
- 
				As far as i know there is no POINTER variable type in o2.
			
- 
				Hi Brian,
 
 this will work for me:
 
 sys ptr p2, ptr p3   (or byte ptr )
 or
 sys *p2, *p3      (or byte * )
 
 I also think that this is more logical:
 
 print chr(65,13,10)
 or
 print chr(p1)  chr(13, 10)
 
 I am surprised that byte * does work, I thought there is a difference between char and byte?
 
 Roland
- 
				Yes, ptr and '*' are interchangeable, and these are associated with each variable rather than the type itself.
 
 I'll need to trap impossible address assignments:
 
 byte b
 @b=strptr s
 
 
 The variadic form of chr will only work with numbers, but if you need something more flexible:
 '12:07 20/08/2019
 'variadic chr
 function chrs(int n,...) as string
 if n>0
 function=nuls n
 byte b at @param 'param base on stack
 byte c at strptr function
 while n
 @b+=sizeof sys 'next param on stack
 c=b
 @c++
 n--
 wend
 endif
 end function
 '
 byte a=0x41 'A
 byte b=0x42
 byte c=0x43
 print chrs(5,a,b,c,0x44,0x45) 'ABCDE'