wila
15-Nov-2019, 05:19 AM
Hi,
Reading the doc, so figured to install as I was curious about something in there.
Some interesting design decisions that have been made. Certainly within the spirit of the DataFlex language.
It mentions SizeOfWString
So I'm thinking .. hey earlier it was mentioned that length would work with all our strings.. so what is the difference?
Here's my first program in DF20
Use Windows.pkg
WString wsTest
Move (Repeat(Character(0),540)) to wsTest
Showln (SizeOfWString(wsTest))
Showln (Length(wsTest))
winput "test" windowindex
That didn't compile because
----Compiling testWString.src----
- Compiling Program: C:\DataFlex Projects\testing20\AppSrc\testWString.src
- Memory Available: 1195442176
- Using pre-compiled package WINDOWS.PKG
- Including file: windows.x64.pkd (C:\Program Files\DataFlex 20.0\Pkg\windows.x64.pkd)
- Warning 4533: C:\DataFlex Projects\testing20\AppSrc\testWString.src (ln 11) Obsolete command: Winput. Use Message_Box
-- Warning 4533: Obsolete command: GetAddress. Use AddressOf Function
-- Error 4539: Conversion from 64-bit pointer to integer is not allowed, use Longptr instead of Integer.
-- Error 4539: Illegal datatype conversion (would lead to a runtime error if not corrected)
- Summary
- Memory Available: 1192370176
- Total Warnings : 2
- Total Errors : 2
- Total Symbols : 9444
- Total Resources: 0
- Total Commands : 7973
- Total Windows : 0
- Total Pages : 0
- Static Data : 93735
- Message area : 44399
- Total Blocks : 5219
- 2 ERRORS HAVE BEEN FOUND.
----Compile Finished (with Errors and Warnings) ----
----Compiler Warning Summary----
- Warning 4533: C:\DataFlex Projects\testing20\AppSrc\testWString.src (ln 11) Obsolete command: Winput. Use Message_Box
-- Warning 4533: Obsolete command: GetAddress. Use AddressOf Function
----Compiler Error Summary----
- Error 4539: Conversion from 64-bit pointer to integer is not allowed, use Longptr instead of Integer.
-- Error 4539: Illegal datatype conversion (would lead to a runtime error if not corrected)
Hmm.. this works:
Use Windows.pkg
WString wsTest
Move (Repeat(Character(0),540)) to wsTest
Showln (SizeOfWString(wsTest))
Showln (Length(wsTest))
winput windowindex
The output is.....
80
80
Uhhh...
Moving all that global code over to a method gives:
Use Windows.pkg
Procedure test
WString wsTest
Move (Repeat(Character(0),540)) to wsTest
Showln (SizeOfWString(wsTest))
Showln (Length(wsTest))
End_Procedure
Send Test
winput windowindex
output is:
540
540
That's all very interesting...
1. globals are still causing trouble
2. Winput doesn't like the string prompts
3. Still not sure what the difference is between SizeOfWString and length except that the former is more explicit and will not trigger any implicit conversions to UTF-8
Now I guess that 3. is what answers my question after thinking about it, but it was an interesting test with surprising results, so figured to post it here.
--
Wil
Reading the doc, so figured to install as I was curious about something in there.
Some interesting design decisions that have been made. Certainly within the spirit of the DataFlex language.
It mentions SizeOfWString
So I'm thinking .. hey earlier it was mentioned that length would work with all our strings.. so what is the difference?
Here's my first program in DF20
Use Windows.pkg
WString wsTest
Move (Repeat(Character(0),540)) to wsTest
Showln (SizeOfWString(wsTest))
Showln (Length(wsTest))
winput "test" windowindex
That didn't compile because
----Compiling testWString.src----
- Compiling Program: C:\DataFlex Projects\testing20\AppSrc\testWString.src
- Memory Available: 1195442176
- Using pre-compiled package WINDOWS.PKG
- Including file: windows.x64.pkd (C:\Program Files\DataFlex 20.0\Pkg\windows.x64.pkd)
- Warning 4533: C:\DataFlex Projects\testing20\AppSrc\testWString.src (ln 11) Obsolete command: Winput. Use Message_Box
-- Warning 4533: Obsolete command: GetAddress. Use AddressOf Function
-- Error 4539: Conversion from 64-bit pointer to integer is not allowed, use Longptr instead of Integer.
-- Error 4539: Illegal datatype conversion (would lead to a runtime error if not corrected)
- Summary
- Memory Available: 1192370176
- Total Warnings : 2
- Total Errors : 2
- Total Symbols : 9444
- Total Resources: 0
- Total Commands : 7973
- Total Windows : 0
- Total Pages : 0
- Static Data : 93735
- Message area : 44399
- Total Blocks : 5219
- 2 ERRORS HAVE BEEN FOUND.
----Compile Finished (with Errors and Warnings) ----
----Compiler Warning Summary----
- Warning 4533: C:\DataFlex Projects\testing20\AppSrc\testWString.src (ln 11) Obsolete command: Winput. Use Message_Box
-- Warning 4533: Obsolete command: GetAddress. Use AddressOf Function
----Compiler Error Summary----
- Error 4539: Conversion from 64-bit pointer to integer is not allowed, use Longptr instead of Integer.
-- Error 4539: Illegal datatype conversion (would lead to a runtime error if not corrected)
Hmm.. this works:
Use Windows.pkg
WString wsTest
Move (Repeat(Character(0),540)) to wsTest
Showln (SizeOfWString(wsTest))
Showln (Length(wsTest))
winput windowindex
The output is.....
80
80
Uhhh...
Moving all that global code over to a method gives:
Use Windows.pkg
Procedure test
WString wsTest
Move (Repeat(Character(0),540)) to wsTest
Showln (SizeOfWString(wsTest))
Showln (Length(wsTest))
End_Procedure
Send Test
winput windowindex
output is:
540
540
That's all very interesting...
1. globals are still causing trouble
2. Winput doesn't like the string prompts
3. Still not sure what the difference is between SizeOfWString and length except that the former is more explicit and will not trigger any implicit conversions to UTF-8
Now I guess that 3. is what answers my question after thinking about it, but it was an interesting test with surprising results, so figured to post it here.
--
Wil