Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / New BUG found - right$ function with big string

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. New BUG found - right$ function with big string
#4958
Posted by: lupomilvio 2004-08-06 16:58:49
I haven't found any post on this bug.
The right$ function doesn't work properly with >32k strings.

This code show the bug:

' the program creates a big string and uses right$ and mid$ functions to get the last 20 chars
' You'll see that when the string become bigger than 32k the results are different!!!

 CONST CRLF=CHR$(13)+CHR$(10)
 DIM ww AS STRING, i AS INTEGER
'**********************************************
 SUB testit

  ww=""

  DO
   ww=ww+STR$(LEN(ww))+"-"
  LOOP UNTIL LEN(ww)>10000

  SHOWMESSAGE "LEN="+STR$(LEN(ww))+CRLF+CRLF+"RIGHT$" + CRLF +RIGHT$(ww,20) + CRLF + CRLF+"MID$" + CHR$(13)+CHR$(10)+MID$(ww,LEN(ww)-19,20)


  DO
   ww=ww+STR$(LEN(ww))+"-"
  LOOP UNTIL LEN(ww)>20000

  SHOWMESSAGE "LEN="+STR$(LEN(ww))+CRLF+CRLF+"RIGHT$" + CRLF +RIGHT$(ww,20) + CRLF + CRLF+"MID$" + CHR$(13)+CHR$(10)+MID$(ww,LEN(ww)-19,20)


  DO
   ww=ww+STR$(LEN(ww))+"-"
  LOOP UNTIL LEN(ww)>30000

  SHOWMESSAGE "LEN="+STR$(LEN(ww))+CRLF+CRLF+"RIGHT$" + CRLF +RIGHT$(ww,20) + CRLF + CRLF+"MID$" + CHR$(13)+CHR$(10)+MID$(ww,LEN(ww)-19,20)


  DO
   ww=ww+STR$(LEN(ww))+"-"
  LOOP UNTIL LEN(ww)>40000

  SHOWMESSAGE "LEN="+STR$(LEN(ww))+CRLF+CRLF+"RIGHT$" + CRLF +RIGHT$(ww,20) + CRLF + CRLF+"MID$" + CHR$(13)+CHR$(10)+MID$(ww,LEN(ww)-19,20)

  DO
   ww=ww+STR$(LEN(ww))+"-"
  LOOP UNTIL LEN(ww)>50000

  SHOWMESSAGE "LEN="+STR$(LEN(ww))+CRLF+CRLF+"RIGHT$" + CRLF +RIGHT$(ww,20) + CRLF + CRLF+"MID$" + CHR$(13)+CHR$(10)+MID$(ww,LEN(ww)-19,20)
 END SUB
'**********************************************

 CREATE Form AS QFORM
  CAPTION = "Form1"
  Width = 320
  Height = 240
  Center
  CREATE Button1 AS QBUTTON
   CAPTION = "Button1"
   Left = 82
   Top = 48
   onclick=testit
  END CREATE
 END CREATE

'Insert your initialization code here

 Form.SHOWMODAL
Greetings
Lupo
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥908.00 ·
 
 
¥1,380.00 ·
 
 
¥1,580.00 ·
 
 
¥890.00 ·
 
 
¥1,800.00 ·
 
 
¥294.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0