April 26, 2024, 04:53:52 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


"New" and IStrings

Started by LarryMc, June 25, 2007, 04:34:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

I'm having a problem getting a test program to work and for the life of me I can't see why.

pointer ptr
istring a$[100000],b$[100000]

OPENCONSOLE
' load a$ with < 100,000 characters
a$=string$(99990,"@")+"999"
' set aside memory to hold it
ptr = NEW(Char,len(a$)+1)
' load memory with contents of a$
#<string>ptr=a$
' prove contents of a$ is in memory pointed to by ptr
a$=""
pRINT "This is 1st character ",#<string>ptr[0]
pRINT "This is last character ",#<string>ptr[99999]
' but this causes a crash here
'print #<string>ptr
' what I now want to do is load the contents of the memory pointed to
' by ptr into the varable b$.
b$ = #<string>ptr
' the length of b$ indicates the transfer was made
print len(b$)
' although caused a crash above it works here
print #<string>ptr

' this line won't print
print "[",b$,"]"
a$=b$
' and this line won't print
print "[",a$,"]"
    a$=""
' but this will print
print "[",a$,"]"

DELETE ptr


PRINT "PRESS <ANY> KEY TO END!"
DO:UNTIL INKEY$<>""
END

I know the answer is simple and obvious but I've played with it every different way I can think of and I can't make it work.

Edit: If I keep the size of the the string (a$) to less than 53216 it appears to work okay; even if I set aside 100,000 chars with the new command.

HELLLLLLPPPPPPPP!!!! ??? ???
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

REDEBOLT

Regards,
Bob

LarryMc

Bob,

Thanks a million$!

I've been beating my head against the wall all day over that.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

REDEBOLT

Quote from: Larry McCaughn on June 25, 2007, 06:17:14 PM
Thanks a million$!

Your invoice is in the mail!
:D

P.S.  Just kidding.
;D
Regards,
Bob

LarryMc

The real kicker is that I was printing only for debugging purposes.  The contents actually goes to a file, which works fine.

It does kill one little feature of the program I'm working on.

In my filesave function I had it so it would go to the screen if you passed it file name of "2screen"; otherwise it would go to a file.

Can't use that now if a have a variable value greater than that 50,000+

And it's probably not something Paul will fix anytime soon with his current focus on Linux, the courses, and his new job.

And as I "ALWAYS" tell my creditors.....

"Checks in the mail!"

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library