IonicWind Software

IWBasic => General Questions => Topic started by: Andy on January 14, 2016, 05:33:11 AM

Title: IWSTRING, TSTRING and ITSTRING
Post by: Andy on January 14, 2016, 05:33:11 AM
Hi,

After posting my latest update to my "String Theory" offering,

http://www.ionicwind.com/forums/index.php?topic=5802.0 (you can download the latest version - at the end of the post).

Larry did mention about Wstrings and Tstrings which I was debating about to myself, so I thought I would look a little closer.

I have compiled the examples for IWSTRING and ITSTRING and they don't compile.

OPENCONSOLE

'Define a string of exactly 30 characters

DEF name[30]:IWSTRING

name = L"john Smith"

name[0] = L"J"

PRINT W2S(name)

PRINT "Press any key to close"

DO:UNTIL INKEY$ <> ""

CLOSECONSOLE

END


Gives an "cannont assign wstring to word" error for the line - name[0] = L"J"
and It's the same for the Tstring example.

So, It's probably me, or am I missing something here...

It would be interesting to look at adding unicode characters to the string program, it depends for me on how much work would be involved, and how many people would think it useful.

Thanks,
Andy.
:) 
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: LarryMc on January 14, 2016, 05:48:14 AM
get rid of the '
  • [/b]'
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: Andy on January 14, 2016, 05:54:41 AM
Sorry Larry,

You've lost me on that one?

Andy.

Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: LarryMc on January 14, 2016, 06:01:54 AM
get rid of the '[0]'
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: Andy on January 14, 2016, 06:16:21 AM
When I do that, the string just becomes "J" instead of "John Smith".


Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: LarryMc on January 14, 2016, 10:12:10 AM
Quote from: andy1966 on January 14, 2016, 06:16:21 AM
When I do that, the string just becomes "J" instead of "John Smith".
duh
That's what the program you posted told it to do
DEF name[30]:IWSTRING

name = L"john Smith"

name = L"J"

PRINT W2S(name)
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: Andy on January 14, 2016, 10:34:25 AM
No Larry,
That's what you said I needed to change.

And we are only amending the examle program, not mine!

It doesn't work as stated.
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: LarryMc on January 14, 2016, 10:52:07 AM
Now I'm confused.
I this thread you posted this code
OPENCONSOLE

'Define a string of exactly 30 characters

DEF name[30]:IWSTRING

name = L"john Smith"

name[0] = L"J"

PRINT W2S(name)

PRINT "Press any key to close"

DO:UNTIL INKEY$ <> ""

which you said wouldn't compile because it gave you an error on line 10
which is this line
name[0] = L"J"
I tried to compiled the program and duplicated your result.
I changed line 10 to read
name = L"J"
It compiled fine and printed
QuoteJ
as you would expect from the code
I commented out line 10 and recompiled/ran.
The output was
Quotejohn Smith
as expected from the posted code.

So what are you saying is wrong?
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: Andy on January 14, 2016, 10:55:02 AM
The j should be a capital J not j (lower case).

So it should print John Smith not john Smith.
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: LarryMc on January 14, 2016, 06:59:21 PM
It finally dawned on me that in line 10 you were trying to substitute the 1st character in the string to replace the small j with a caps J.  That's a super sized DUH on me.  Mark it down to a senior moment. ::) ::)

Looks to me like you have found a bug in the compiler; thats the only way I can explain it.

We'll have to put it down for LarryS.
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: Andy on January 15, 2016, 05:38:18 AM
Looks like It's a bug Larry,

Don't mean to find these things, and I really hate being a pain in the you know what! that's not why I ask questions.

Andy.
:)
Title: Re: IWSTRING, TSTRING and ITSTRING
Post by: LarryMc on January 15, 2016, 05:46:13 AM
It's not being a pain when you find a bug; generally speaking, when you identify and document a bug, you are saving other people a lot of pain because they don't have to go through the same discovery process you did.

So I say "thank you"