Oxygen Basic

Information => Development => Topic started by: Brian Alvarez on May 25, 2019, 09:15:11 AM

Title: Fixed length ZSTRING2 vs Dynamic length ZSTRING2
Post by: Brian Alvarez on May 25, 2019, 09:15:11 AM
 This is giving me hell (pun intended):

Code: [Select]
FUNCTION TESTIT1(zstring2 zText) AS LONG
   print ztext
   print chr(13, 10) ' print separately to make sure we are not contaminating the ztext
END FUNCTION

FUNCTION TESTIT2(zstring2 zText[32]) AS LONG
   print ztext
   print chr(13, 10) ' print separately to make sure we are not contaminating the ztext
END FUNCTION

ZSTRING2 test1
ZSTRING2 test2[32]

test1 = "Hello World"
test2 = "World Hello"

testit1 test1
testit2 test1
testit1 test2
testit2 test2

The output is:

Code: [Select]
Hell
HellWorld Hello
Worl
World Hello

 I dont know if this is the data in the test variables being corrupted or print not being able to display the strings correctly,

 If the first case, how can i make sure i am not doing anything wrong?

 If the second case, How can i convert the strings for correct display?
Title: Re: Fixed length ZSTRING2 vs Dynamic length ZSTRING2
Post by: JRS on May 25, 2019, 09:24:35 AM
HELLO2  ;D
Title: Re: Fixed length ZSTRING2 vs Dynamic length ZSTRING2
Post by: Aurel on May 25, 2019, 10:35:10 AM
Yo Brian
This work:
 
FUNCTION TESTIT1(byref ztext as zstring2 ) AS LONG
   print ztext
   print chr(13, 10) ' print separately to make sure we are not contaminating the ztext
END FUNCTION

FUNCTION TESTIT2(zstring2 zText[32]) AS LONG
   print ztext
   print chr(13, 10) ' print separately to make sure we are not contaminating the ztext
END FUNCTION

ZSTRING2 test1 = "Hello World"
ZSTRING2 test2[32] = "World-Hello"

testit1 (test1)
testit2 test1
testit1 test2
testit2 test2

You confuse o2 with declare nothing then with declare something  :D
Title: Re: Fixed length ZSTRING2 vs Dynamic length ZSTRING2
Post by: Brian Alvarez on May 25, 2019, 12:01:04 PM
Thanks Aurel. This makes sense. :)

 I thought the ZSTRING2 was dynamic length because it was allowing me to define it with no initial contents.