Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The number in Replicate creates a problem
Message
 
 
To
05/04/2022 11:19:00
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
01684050
Message ID:
01684074
Views:
38
>>>>>>
>>>>>>REPLICATE(' ',10-LEN(ALLTRIM(REFERENCE)))
>>>>>>
>>>...
>>>>>>Now the above code does not work. The SQL Select returns the error:
>>>>>>
>>>>>>String is too long to fit.
>>>
>>>>>>If I change the 10 in the above REPLICATE with 15, no error.  
>>>>>>REPLICATE(' ',15-LEN(ALLTRIM(REFERENCE)))
>>>>>>
>>>Just a thought (hope nobody elese in the thread below also has already mentioned it)
>>>this error can crop up with negative 2nd parameter. so if somewhen len (alltr()) .EQ. 11...
>>>
>>>HTH
>>>thomas
>>
>>This was not the case. I actually checked all the value in the table. The table is somewhat small, only about 20 rows, so it was easy to spot this. Plus, up until yesterday, the value in the field could not be more than 10 characters, since this was the length of the field. When I changed the length of the field from 10 to 15, the problem started.
>>Thank you.
>
>@Thomas Aber sicher. message #01684058
>
>@Dimitry
>But you agree that REPLICATE(' ',10-LEN(ALLTRIM(REFERENCE))) might result in a negative for 10-LEN(ALLTRIM(REFERENCE)), if REFERENCE is c(15)?
>
>You need to know, the calculation of field length might do things different then filling the fields. It have it's own ideas how to deal with ALLTRIM, because else something like
>SELECT ALLTRIM(bla) AS blu
>might, depending on first record be C(0) to c(whatever)
>So, I guess this simply will do something like ignoring ALLTRIM to determine fieldlenght, and then it's -5
>
>If you like to see this in action, try:
>
>PUBLIC piX
>piX = 0
>CREA CURSOR mycur (i1 I, c1 c(10))
>INSERT INTO mycur VALUES (0,'')
>SELE i1, myfunc(ALLTRIM(c1)) AS mi FROM mycur
>
>FUNCT myfunc (tc1)
> ?LEN(tc1)
> piX = piX+1
> RETURN piX
>ENDFUNC
>
>You see that there is an additional call to myfunc returning 10 for tc1? This is to figure out the structure of the result cursor

I am copying your lines for clarity:
>> But you agree that REPLICATE(' ',10-LEN(ALLTRIM(REFERENCE))) might result in a negative for 10->> LEN(ALLTRIM(REFERENCE)), if REFERENCE is c(15)?

Even though the field REFERENCE is c(15), none of the entries are greater than 10. So the REPLICATE('',10-LEN(ALLTRIM(REFERENCE))) can never be a negative number.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform