×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Search Combo Box revisited
2

Search Combo Box revisited

Search Combo Box revisited

(OP)
Hi Guys,

I tried to create a Search Combo Box like you were discussed in thread184-1312767: Combobox like Google's?.
Also tried Mike Gagnon's solution with the ComboBox Interactive Event modification in FAQ184-1792: How to create a "auto-fill" style combobox AND allows to add value not found.
Both solution does what it supposed to, with one flaw: neither of them works with international characters.
Does anyone have an idea to circumvent this problem?

RE: Search Combo Box revisited

What do you mean by "international characters"? Do you perhaps mean letters with accents and diacryticals, such as à and é?

If so, Mike Gagnon's auto-fill combo box should still work, but with one small modification. In the InteractiveChange event, look for this line:

CODE -->

IF (lnLastKey>=32 and lnLastKey<=126) 

and change it to

CODE -->

IF (lnLastKey>=32 and lnLastKey<=255) 

The effect will be to include all characters in the so-called upper-ASCII range, which includes accented letters, diphthongs, currency symbols and certain others.

But have you also considered using a textbox with Autocomplete set to .T.? That will give you the same benefits as an auto-fill combo, but with considerably less effort.

Mike





__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Search Combo Box revisited

Mike,
Your solution to extend to chr(255) will work, but what happens if user types an 'unwanted' character like e.g. [ ?
Presently I have to validate that only normal alphabet characters (a~z), numbers 1~0 and all accented characters ä ~ ý are allowed have therefore coded

CODE --> vfp

lcValue = Alltrim(Lower(This.Value))
Do Case
	Case Inlist(m.lcValue,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u')
		lcLettervalu = m.lcValue
	Case Inlist(m.lcValue,'v','w','x','y','z','ä','á','à','ë','è','é','ï','í','ì','ö','ó','&ograve;','ü','&uacute;','&ugrave;','ç','ý')
		lcLettervalu = m.lcValue
	Case Inlist(m.lcValue,'1','2','3','4','5','6','7','8','9','9','ø','ñ','æ','å','ß','ã')
		lcLettervalu = m.lcValue
endcase 

was 'forced' to break it into 3 cases since inlist has a restricted length not covering the lot.

This solution, in my opinion is however clumsy and should be recoded into something more elaborate, haven't yet found it and meanwhile, since 'it works - it works'

Regards,

Koen

Please not that this site changed some accented characers into like '&ograve' a.s.o in my vfp coding it is just an o with the accent grave, don't know why this happens with the o u letters only.

RE: Search Combo Box revisited

Olaf,

Thanks, isalpha an isdigit will be much better. One exception: ý this character, which is part of the Dutch alphabet however since it is very rarely used, we normally just type ij to get the effect and very few people make use of the key-combination '+y to get that letter I can accept that 'bug'. Thanks.

Koen

RE: Search Combo Box revisited

Besides you could also put all the characters you want to allow in a single string - it'll also be shorter than 256 characters automatically, and then use the $ operator (is contained in) or check AT()>0 or OCCURS() function, many ways to solve that without INLIST.

Besides preventing those as last key, you could just filter unwanted characters from the value even after they are in it already. Mike Gagnons code actually redoes the base behaviour of keypress (before interactivechange) by working on displayvalue instead of value and by keeping displayvalue at what you types, so the natural working of value is overridden.

But you could simpler work retroactive you accept any input as normal and then remove unwanted characters.

I just checked out what lastkey() is when I use backspace: 127. Besides Ascii code is 8. That would not be allowed. Even for autocomplete I'd like to be able to backspace..., you don't get along very well if you just compare chr(lastkey()) to allowed characters.

I'd also plead for a textbox with autocomplete instead.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

Quote:

Your solution to extend to chr(255) will work, but what happens if user types an 'unwanted' character like e.g. [ ?

Your right, Koen. But that's the same situation as with Mike Gagnon's original solution. If there is an entry in the combo that contains, say, a square bracket, then pressing that key will find it. Whether that's correct or not depends on what you want to achieve. If you want to limit the search to alphabetical characters, then I agree that a test for ISALPHA() would be better.

Of course, we are making assumptions about what the original questioner means by "international characters". It would be useful if he could clarify that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Search Combo Box revisited

Olaf,

so we have
  • inlist()
  • isalpha()
  • occurs() $
  • at() $
all doing basicly the same, where I believe isalpha is the shortest.
Thanks,
Koen

RE: Search Combo Box revisited

  1. inlilst() -> limited to 27 items
  2. isalpha() only good for alphabetic, can be extended using isdigit()
  3. at(newchar,listofallowedchars)>0, occurs(newchar,listofallowedcahrs) or (newchar $ listofallowedchar) being the most versatile to use, as they can cover more than characters and digits.
The $ operator is most to the pont for this test, as you only need to know whether the newly entered char is in the allowed list, neither where (at) it is not how often it (occurs) it exists.
Don't you know the $ operator?

CODE

If lcNewChar $ "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÓÔÕÖÛÜÝÞßàáâãäåæçèéêëìíîïðñóôõöøûüýþÿ0123456789.,:;?(){]" 

This will check whether the new input is space (notice the space between uppercase an lowercase normal english latin letters), any letters (aside of some the forum translates awkwardly into html entities), any digits and some more and you can configure it to any set of characters you want to allow.

And this approach is very well known. For example in thread184-1673722: Validation of text box or in thread184-1476889: STRTRAN() performance

Still, whether you limit the value of lastkey or check the char is in a certain list you disallow keys that have no valid cahracter but are a valid action like delete or backspace, therefore I suggested to go the other route and check Value for invalid characters and remove them.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

ISALPHA() is definitely the shortest. More to the point, it doesn't depend on the programmer working out in advance which letters to include. Assuming our intepretation of "international characters" is correct, that choice is built into the function.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Search Combo Box revisited

I question the whole approach anyway, because this doesn't allow to edit the searchtext. Even just the normal intellisnese in VFPs code editing allows you to backspace.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

I agree. And what about the earlier suggestion of using a textbox with Autocomplete set to .T.?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Search Combo Box revisited

(OP)
Dear All,
thank you for all the answers.
The fact of the matter is I tried both aforementioned approach: the modified combobox and the textbox with autocomplete. Both of them has disadvantages.
- The textbox with autocomplete would be the smoother solution, but it does not accept accented national characters. It just doesn't. I tried to use it with a couple of hundred predefined search suggestions which I fill in the textbox's Init method. It works well until I only use only the classic latin letters.
- The Combobox accepts accented characters after Olaf's ISALPHA() check modification, but does not open down with the suggestions. I even tried to call this.dropdown from the interactivechange method from the key detection, but no avail. (it also requires to create four additional properties in the combobox class which never really use later. I didn't really understand this, but I've found they can be left out)

RE: Search Combo Box revisited

You mean these 4 properties:

1. acstyle (Default value = 2)
2. lastdisplayvalue (Default value = [none])
3. lastsellength (Default value = 0)
4. lastselstart (Default value = 0)

Well, they are used by the code given.

Quote (herbstgy)

which never really use later

well, then you haven't used the given code.

Besides that

Quote (herbstgy)

The textbox with autocomplete would be the smoother solution, but it does not accept accented national characters.

I also can't aay that, you must have populated the "search suggestions" wrong. You wouldn't do that in init, but prepare an autocomplete table.

If you simply set 'AutoComplete to 1 and let VFP create the necessary DBF for autocomplete sure this will also record International characters and search b them:

I don't used a specific Autocomplete Table, but you can copy out the one VFP automatically uses as described in the help at Home(7)+"autocomp.dbf" and put in our initial data.

Did you read into the topic well enough to define your autocomplete data the way it's needed for your case? It doesn't seem so.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

Quote:

The textbox with autocomplete would be the smoother solution, but it does not accept accented national characters. It just doesn't. I tried to use it with a couple of hundred predefined search suggestions which I fill in the textbox's Init method. It works well until I only use only the classic latin letters.

That's not the normal way to use autocomplete. It's not the programmer's job to populate the table. That's done for your automatically from the user's entries. In fact, that's the whole point of autocomplete. It "learns" your data from what has been entered previously.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Search Combo Box revisited

Well, you can populate it, and the advanced feature of weighted suggestions or ordering by frequency even ask for it. You just have to use the DBF structure as given for AutoComp tables. You can't just use any list of values as AutoComp table. The possibilities are much more vast than simple autocomplete or intellisense, though the latter has a specialty in showing parametrizations of functions, for example. By the way the intellisense feature of VFP can also be used at runtime in edit memo windows or even editboxes, IIRC. Doug Henning has some white paper on that, I doubt this is for you, when you even don't get into the details of a code example or the AutoComplete feature. What you expose here doesn't look like just bad luck, sorry to say so, but success is not instant, if you give up after the first try and even make wrong accusations that won't give you much joy, and I only think about the effect you have on your own to yourself, not the responses you get from a forum about that. AutoComplete really just even needs to be set to 1 to work off hands, if you want to populate suggestions just enter one, read the help topic in all detail to know VFP stores a table in Home(7)+"autocomp.dbf", take that dbf and expand it with your suggestions. As easy as that.

I can't reproduce the disadvantage you found about international characters, unless you tell me you want to use international characters not available to any ANSI code page you could use in VFP. I'd like to understand your problem, but you don't even tell what you tried. And what you tell about the usage of Mike Gagnons code is you haven't used it as intended, as the four given new properties are used in the code.

In regard to international characters: Besides the given AutoComp structure you can choose codepage and collation sequence as you like, as long as VFP supports it. VFP has support for simplified Chinese and I think also Japanese, Ansi 1252 supports many special characters of german, french, scandinavian or slavic languages, greek is another matter again, and then there are alphabets VFP doesn't support at all, like indian Urdu.

The characters you have in Ansi 1252 are shown above, all those are available and some more (I already said above I skippped some as the forum processes them to HTML entities).

If you only give it a try and never even come to a forum asking why something doesn't work as expected with your code, you'll never know why, especially if you give up before you even dig into the details of the family of properties and data working hand in hand with the autocomplete feature. It's really offering very advanced and even more modes than I'd ask of an autocomplete mode with the little as data structure it needs.

The need or the wish to prepopulate it asks you to read into the concept in more details than just setting AutoComplete=1 and AutoCompTable to any table. I'm reminded about a situation someone just did set a DBF with a single column of values and expected this to be taken as suggestions. You get what you deserve, if you don't read the manual or follow the given instructions of a FAQ.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

(OP)

Quote (Olaf)


If you simply set 'AutoComplete to 1 and let VFP create the necessary DBF for autocomplete sure this will also record International characters and search b them:
I don't used a specific Autocomplete Table, but you can copy out the one VFP automatically uses as described in the help at Home(7)+"autocomp.dbf" and put in our initial data.
Did you read into the topic well enough to define your autocomplete data the way it's needed for your case? It doesn't seem so.

That I did. I don't really understand why you assume the opposite. Here's the code I used:

CODE --> Foxpro

SELECT DISTINCT ALLTRIM(addr_city)+' '+ALLTRIM(addr_street)+' '+TRANSFORM(addr_number,'@Z 999.')+' '+ALLTRIM(company) AS srchdata ;
 FROM gepek ;
 WHERE alive ;
 ORDER BY 1 ;
 INTO CURSOR srchdata
DELETE FILE (HOME(7)+"qsrch.dbf")
CREATE TABLE (HOME(7)+"qsrch.dbf") (Source C(20),Data C(254),Count I,Weight I,Created T,updated T,user M)
INSERT INTO qsrch (Source,Data,count,created,updated) ;
 SELECT "txtQsrch",srchdata,1,DATETIME(),DATETIME() FROM srchdata
USE IN qsrch
USE IN srchdata
WITH this
	.AutoCompSource="txtQsrch"
	.AutoCompTable=(HOME(7)+"qsrch.dbf")
	.AutoComplete= 1
ENDWITH 

it simply builds a table named qsrch.dbf in the HOME(7) dir with the same structure as autocomp.dbf. and it works, apart from the accented characters...

Quote (Olaf)

I also can't aay that, you must have populated the "search suggestions" wrong.

that was my first thought too. :)
so I tried without the predefined suggestions, and let VFP to fill the autocomp.dbf as it wants...
same thing, it fails on the accented characters.
I'm out of ideas here...

(also, can't upload pics to illustrate my problem. but that's just the icing on the cake.)

RE: Search Combo Box revisited

(OP)

Quote (Olaf)

You mean these 4 properties:

1. acstyle (Default value = 2)
2. lastdisplayvalue (Default value = [none])
3. lastsellength (Default value = 0)
4. lastselstart (Default value = 0)

Well, they are used by the code given.

Quote (herbstgy)
which never really use later

well, then you haven't used the given code.

yes, I meant those properties in FAQ184-1792: How to create a "auto-fill" style combobox AND allows to add value not found.
and this code:

CODE --> Foxpro

In the InterActive Event of the ComboBox:


LOCAL lnStyle, lnLastKey, lcDisplayValue
lnLastKey=lastkey()
lnStyle = this.style
IF this.style = 2
    this.style = 0
ENDI
IF (lnLastKey>=32 and lnLastKey<=126)
    IF this.selstart>=1
        lcDisplayValue=substr(this.displayvalue,1,this.selstart-1)+(chr(lnLastKey))
    ELSE
        lcDisplayValue=(chr(lnLastKey))+allt(this.displayvalue)
    ENDI
    IF empty(lcDisplayValue)
        lcDisplayValue=allt(chr(lnLastKey))
    ENDI
    FOR i = 1 to this.listcount
            If Upper(lcDisplayValue) == Upper(Substr(This.List(i),1,Len(lcDisplayValue)))
                This.DisplayValue=This.List(i)
                This.SelStart=Len(lcDisplayValue)
                nlLength=Len(Allt(This.DisplayValue))-Len(lcDisplayValue)
                This.SelLength=Iif(nlLength <0,0,nlLength)
                this.lastdisplayvalue = this.displayvalue
                this.lastselstart = this.selstart
                this.lastsellength = this.sellength
                RETURN
            ENDI
    ENDFOR
ENDIf


In the combobox requery:


this.Value = this.DisplayValue && Just to reset the display value


In the valid of the combobox:


If !Empty(This.DisplayValue)
    Local cTableName,cFieldName,nAnswer,cValue
    Store Juststem(This.RowSource) To cTableName &&Won't work for VFP5.0
    Store Justext(This.RowSource) To cFieldName && This is normally used for 3 character extension, but it works for any lenght. Won't work for VFP5.0
    Select (cTableName)
    Locate For &cFieldName = This.DisplayValue
    If !Found()
        nAnswer = Messagebox("This value was not found in the table,"+Chr(13)+"Do you want to save it in the table?",36,"")
        If nAnswer = 6
            Insert Into &cTableName (&cFieldName) Values (This.DisplayValue)
            If CursorGetProp("Buffering") > 1  && Check to see if we should use tableupdate
                Tableupdate(1,.T.,cTableName)
            ENDIF
        this.Requery() && To reset the display value
        Else
            Store '' To This.DisplayValue
        Endif
    Endif
ENDIF 

could you point out where those properties are actually used? maybe I'm really missing something here.

but that's really beside the point.
this combobox solution could really be used instead of textbox autocomplete, if the popup part would open automatically as the user starts typing in it. could you help with that?

RE: Search Combo Box revisited

Well, I have to make some assumptions of doing something wrong when it doesn't work for you. Your code doesn't show your data, but my screenshot was already showing autocomplete reacting to German umlauts, if that doesn't prove anything to you I can't help you.

The first problem I see in your approach is trying to create a table into HOME(). This by default is in Program Files directory write protected and you'll likely find your DBF in your profile in some subfolder of C:\Users\%Username%\AppData\Roaming\Microsoft\Visual FoxPro 9}...

So you're doing this too literally as VFP. VFP has one advantage: It has installed this DBF where it is, during installation you can write files and such writes are not redirected. Do you know such mechanisms as write redirections since Vista? So first criticism is: Store your data in your own directories. The way VFP works with his central DBF is surely something you would need to replace when you deploy your application anyway.

Next, I can't judge what your expression ALLTRIM(addr_city)+' '+ALLTRIM(addr_street)+' '+TRANSFORM(addr_number,'@Z 999.')+' '+ALLTRIM(company) AS srchdata results in, I don't have your gepek.dbf

And in regard what I told about codepage, what is CPDBF("gepek.dbf") Is that the same code as you create with your CREATE TABLE statement? You obviously miss, that CREATE TABLE has a codepage=nnnn option, and if you don't use that and create a dbf with VFPs default codepage, which will depend on your locale, yes - of course - you are likely destroying your data because your insert of the data isn't converting anything. You can only copy this way when the source and target DBF have the same codepage.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

Where are the four properties used?

CODE

FOR i = 1 to this.listcount
            If Upper(lcDisplayValue) == Upper(Substr(This.List(i),1,Len(lcDisplayValue)))
                This.DisplayValue=This.List(i)
                This.SelStart=Len(lcDisplayValue)
                nlLength=Len(Allt(This.DisplayValue))-Len(lcDisplayValue)
                This.SelLength=Iif(nlLength <0,0,nlLength)
                this.lastdisplayvalue = this.displayvalue
                this.lastselstart = this.selstart
                this.lastsellength = this.sellength
                RETURN
            ENDI
    ENDFOR 

Indeed I don't see acstyle used or have an idea why it is defined, the code acts directly in the native Style property. But these three properties are a central part of making the code work remembering the situation of the last interactive change, as that already changed in the native properties when the event happens, THIS.Value is already the new value, and the way Mike Gagnon picks up on the old is remembering lastdisplayvalue. The code is really just a few lines, if you don't understand what something is doing feel free to ask.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

(OP)

Quote (Olaf)

The code is really just a few lines, if you don't understand what something is doing feel free to ask.

Thank you, Olaf.

Yes, I saw those lines in the code you emphasized. They have given value in those lines, but those values never used later and the properties never referred anywhere else in the code, so I truly don't understand why they needed. :) Maybe I lack some basic knowledge which is elementary for anyone else. :)

RE: Search Combo Box revisited

(OP)

Quote (Olaf)


The first problem I see in your approach is trying to create a table into HOME(). This by default is in Program Files directory write protected and you'll likely find your DBF in your profile in some subfolder of C:\Users\%Username%\AppData\Roaming\Microsoft\Visual FoxPro 9}...
So you're doing this too literally as VFP. VFP has one advantage: It has installed this DBF where it is, during installation you can write files and such writes are not redirected. Do you know such mechanisms as write redirections since Vista? So first criticism is: Store your data in your own directories. The way VFP works with his central DBF is surely something you would need to replace when you deploy your application anyway.

No, sorry. I'm not creating the DBF in HOME(), but in HOME(7), which points to %APPDATA%\Microsoft\Visual FoxPro 9\ which is a read/write directory, and unique to each user.
The DBF is created as it supposed to (that was the first thing I checked) and filled with the expected data. Its codepage is 1250, which is the local default.

Quote (Olaf)


Next, I can't judge what your expression ALLTRIM(addr_city)+' '+ALLTRIM(addr_street)+' '+TRANSFORM(addr_number,'@Z 999.')+' '+ALLTRIM(company) AS srchdata results in, I don't have your gepek.dbf
And in regard what I told about codepage, what is CPDBF("gepek.dbf")

gepek.dbf has a codepage of 852, because it's inherited from an old FoxPro 2.6 for DOS app. yup, that's still a thing. :)
but it's translated by the select statement to 1250 automatically.

Quote (Olaf)


Is that the same code as you create with your CREATE TABLE statement? You obviously miss, that CREATE TABLE has a codepage=nnnn option, and if you don't use that and create a dbf with VFPs default codepage,

no, I didn't miss that. There's a "SET CPCOMPILE TO" command in VFP, by which you can set to create all new tables to the codepage to your liking. It is set to 1250, so any DBF I use is converted in flight to that.
I also tried to set explicitly CODEPAGE=1250 in the CREATE TABLE statement, but the result is the same.
[/quote]

Quote (Olaf)


which will depend on your locale, yes - of course - you are likely destroying your data because your insert of the data isn't converting anything. You can only copy this way when the source and target DBF have the same codepage.

the first thing I checked in qsrch.dbf that if the codepage and the accented characters are correct. they seemingly are.

RE: Search Combo Box revisited

Quote (herbstgy)

t's translated by the select statement to 1250 automatically.
did you check that? Did you browse your qsrch.dbf?
did you do a comparison, I just copied from codepage 850 to 1250 and for example À is not translated correctly.

I suggest you keep the data in the codepage it is to not loose anything. Or you better adapt the migration to corectly convert the data. It's jsut not done by INSERT INTO new.dbf (fields) SELECT ... FROM old.dbf

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

(OP)

Quote (Olaf)

Quote (herbstgy)
t's translated by the select statement to 1250 automatically.
did you check that? Did you browse your qsrch.dbf?
did you do a comparison, I just copied from codepage 850 to 1250 and for example À is not translated correctly.

of course I did. I even checked it by hex view from outside VFP. :)
but let's forget my qsrch.dbf for a moment.
I turned off completely this prepopulated search suggestions and let VFP do its thing with autocomp.dbf.
and it doesn't work as it does for you. :(
Yes, I saw your screenshot and I understand it should be working, but it doesn't.
For example, if I type "b", it shows the all the autocomplete matches starting with "b", that's okay. Among the matches, there's a "Bősárkány" (don't laugh, that's a village name here - it roughly translates to "Bigdragon") the 2nd char is CHR(245). But when I type "Bő", "Bősárkány" doesn't appear in the autocomplete matches. This drives me crazy.
And the punchline is, if I type through "Bősárkány", and press enter (start the search), it shows the searched record as it supposed to! It just doesn't appear in the autocomplete suggestions.

RE: Search Combo Box revisited

CODE --> herbstgy

of course I did. I even checked it by hex view from outside VFP. :) 
Well, the bytes being the same proves there was not translation done.

If you use two different codepages, that have enough overlap in their character set to store the same text, same characters don't necessarily have the same byte values. Indeed if all characters would have the same byte values, that would mean the codepages are identical.

If you want to comapre data, you'll need to convert your old.dbf and new.dbf texts to UTF-8, for example,any encoding that is capable to have all characters of both codepages. And if that data doesn't differ bytewise, then you have equal characters.

Sorry, but bytewise comparison of ANSI data is besides the point.

For example, the ő in your village name Bősárkány doesn't get over to codepage 1252, in which VFPs autocomp table is encoded here, for me.
Your only problems seem to be codepage problems.

I don't get VFP started with codepage 1250, even using a config.fpw with CODEPAGE = 1250. I may continue tomorrow, but you may investigate in the direction codepage problems you have.
Besides CPCompile the CPCurrent() is more important besides dbf

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

(OP)

Quote (Olaf)


Well, the bytes being the same proves there was not translation done.

sorry, I guess you misunderstood me. I checked the DBF's in question. the bytes are not the same, the codepage translation happened as it is intended.

this is the header of the source dbf:

Structure for table:    M:\DATAS\GEPEK.DBF
Number of data records: 4545    
Date of last update:    2018.08.04
Memo file block size:   64
Code Page:              852 


this is the interim cursor, the result of the SELECT statement:

Structure for table:    C:\USERS\HERBSTGY\APPDATA\LOCAL\TEMP\00003AQ101DF.TMP
Number of data records: 2059    
Date of last update:        .  .  
Code Page:              1250    
 
this is the result DBF for the predefined search suggestions:

Structure for table:    C:\USERS\HERBSTGY\APPDATA\ROAMING\MICROSOFT\VISUAL FOXPRO 9\QSRCH.DBF
Number of data records: 2059    
Date of last update:    2018.08.09
Memo file block size:   64
Code Page:              1250 


also, the header of the default AUTOCOMP.DBF:

Structure for table:    C:\USERS\HERBSTGY\APPDATA\ROAMING\MICROSOFT\VISUAL FOXPRO 9\AUTOCOMP.DBF
Number of data records: 9       
Date of last update:    2018.08.09
Memo file block size:   64
Code Page:              1250 


CPCURRENT() value (default VFP codepage): 1250
CPCURRENT(1) value (default Windows codepage): 1250
CPCURRENT(2) value (underlying operating system codepage): 852

there is no additional codepage setting in config.fpw, everything left to default.

RE: Search Combo Box revisited

Now you misunderstood.

To reproduce your problem I need to get my VFP into Codepage 1250 mode, but it doesn't react to a config.fpw so far.
Fine that you checked your headers are having the cirrect codepage numbers,

Did you look at some words/names giving you trouble in a browse, at least?

VFP will use the codepage given in the DBF to display the data, but in my tests the data you transfer is copied 1:1 by byte values, not by the look of the characters.
You must have a problem with your data, because otherwise it will be displayed and found via autocomplete. I'll see if I get my VFP going in CP1250 somehow to test that sepcific case.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

Hi

Quote (Olaf)

Indeed I don't see acstyle used or have an idea why it is defined
the property was replaced with the local lnStyle.
the first coding was:

CODE --> vfp

THIS.acStyle = THIS.Style
IF THIS.Style = 2
   THIS.Style = 0
ENDI

IF (lnLastKey >= 32 and lnLastKey <= 126)
	IF THIS.SelStart >= 1
		lcDisplayValue = SUBSTR(THIS.DisplayValue,1,THIS.SelStart-1)+(CHR(lnLastKey))
	ELSE
		lcDisplayValue = (CHR(lnLastKey))+ALLT(THIS.DisplayValue)
	ENDI
	IF EMPTY(lcDisplayValue)
		lcDisplayValue = ALLT(CHR(lnLastKey))
	ENDI
	FOR i = 1 TO THIS.ListCount
		IF UPPER(lcDisplayValue)==UPPER(SUBSTR(THIS.List(i),1,LEN(lcDisplayValue)))
			THIS.DisplayValue = THIS.List(i)
			WITH ThisForm
				.LastListNumber = i
				.List1.Refresh()
				.List1.Visible = .T.
			ENDWITH	
			THIS.SelStart = LEN(lcDisplayValue)
			nlLength = LEN(ALLT(THIS.DisplayValue))-LEN(lcDisplayValue)
			THIS.SelLength = IIF(nlLength<0,0,nlLength)
			THIS.LastDisplayValue = THIS.DisplayValue
			THIS.LastSelStart = THIS.SelStart
			THIS.LastSelLength = THIS.SelLength
			KEYBOARD '{F4}'
			RETURN
		ENDI
	ENDF
	IF THIS.acStyle = 2
		THIS.DisplayValue = THIS.LastDisplayValue
		THIS.SelStart = THIS.LastSelStart
		THIS.SelLength = THIS.LastSelLength
	ENDIF
ENDI 
Koen

RE: Search Combo Box revisited

The simplest reason, why you don't ever get ő is it's not a character in codepage 1250, the closest you have is ô.
Codepage 1252 gives you ő, but likely misses some other characters for which you choose codepage 1250, you'll have your reasons.

In your old dbf an ő will be byte 0x8B, in codepage 1250 it doesn't exist, in codepage 1252 it is 0xF5.

If I make that change manually I get autocomplete to work with the letter:



All you have is a codepage problem.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

(OP)
of course there is "ő" and capital "Ő" in codepage 1250. this is the default codepage for Eastern European Windows.

RE: Search Combo Box revisited

Well,

https://de.wikipedia.org/wiki/Windows-1250

Do you really think I can't look into a codepage, which characters it has and which not?


The characters most similar to ő or Ő are:

oóôőö and in upper case OÓÔŐÖ

But none of them is ő or Ő.

This is something really very objectively checkable, just copy and paste a ő into a cp1250 dbf and what's coming over is an o.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

OK, sorry, forget about it, as you can see in my screenshot of autocomplete with Bõsárkány, at some step ő changed to õ, and I demonstrated autocomplete with Bõsárkány.

Now redoing that...

I can store the word in a codepage 1250 autocomp table, though pasting ő turns it into o:

I had to hack it to become chr(0xf5):


but I can't get my VFP session to work in that codepage, so I can't type in ő


So what's your case, if you browse your autocomp table, do you find the right character in it, or did the ő become an o or even an õ?
Or do you get as far as in that screenshot and then typing ő fails?

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Search Combo Box revisited

(OP)

Quote (Olaf)

Or do you get as far as in that screenshot and then typing ő fails?

I'd love to, but I'm not really familiar with this forum engine. :)
actually, I tried that days ago.
how do you insert pictures?
I only succeeded to upload one as attachment, but not insert into a post.

RE: Search Combo Box revisited

All I asked for is a description, but to upload an image inline use this icon in the toolbar:



Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close