Author Topic: Fixed length ZSTRING2 vs Dynamic length ZSTRING2  (Read 1122 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Fixed length ZSTRING2 vs Dynamic length ZSTRING2
« 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?
« Last Edit: May 25, 2019, 10:12:11 AM by Brian Alvarez »

JRS

  • Guest
Re: Fixed length ZSTRING2 vs Dynamic length ZSTRING2
« Reply #1 on: May 25, 2019, 09:24:35 AM »
HELLO2  ;D

Aurel

  • Guest
Re: Fixed length ZSTRING2 vs Dynamic length ZSTRING2
« Reply #2 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
« Last Edit: May 25, 2019, 10:42:12 AM by Aurel »

Brian Alvarez

  • Guest
Re: Fixed length ZSTRING2 vs Dynamic length ZSTRING2
« Reply #3 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.
« Last Edit: May 25, 2019, 12:15:31 PM by Brian Alvarez »