Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[VID] Strange problem

 [1/6] from: apwing:zonnet:nl at: 23-May-2004 13:41


Hi all, currently I am developing a small application that displays flags from all over the world off a website. There is also a search option, in order to search for (a part of) a countryname. The REBOL/View version I use is 1.2.46.3.1. I have built in some print statements for debugging purposes and to show the problem exactly. Example session: 1. start the app 2. fill out the search field named "country-find" with the text "ur" 3. click the "Find (next)" button 4. change the contents of the search field named "country-find" to the text "ne" When you look at the displayed lines, you see (among others): Right after push Find (next) button: global/findstr=(ne) country-find/text=(ne) Apparently global/findstr has changed somewhere between the last hit and the press of the "Find (next)" button. However, there is only one place where global/findstr is being changed AFAIK! It was my intention that global/findstr would contain the PREVIOUS searchstring. Please see the attached app Any ideas? TIA With kind regards, Arie van Wingerden -- Binary/unsupported file stripped by Ecartis -- -- Type: text/x-rebol -- File: flags.r

 [2/6] from: carl:cybercraft at: 24-May-2004 0:04


Hi Arie, Attachments are stripped with this list. If possible, just send the script in the body of the email, or if it's too large, place it on a website (if you have one) and just show us the URL. -- Carl Read.

 [3/6] from: apwing:zonnet:nl at: 23-May-2004 14:29


Hi Carl and others, below the asterisks line follows the script ********************************************************************************************* rebol [ Title: "Flag Viewer" Author: "Arie van Wingerden" ] {write/lines %log mold country-flag} global: make object! [ ;********************************************************************** ; The URL of the webpage holding the names of the different countries ; for which a flag is present. ;********************************************************************** allflags: http://www.cia.gov/cia/publications/factbook/docs/flagsoftheworld.html ;********************************************************************** ; The URL of the webpage holding an enlarged flag of a certain country. ; Each country has a specific prefix code, like xx. ; The image of the flag is URL/xx-lgflag.gif. ; The flad description can be found in URL/xx-flag.html ;********************************************************************** flagpage: http://www.cia.gov/cia/publications/factbook/flags/ ;********************************************************************** ; This field will contain (after get-flags has been called) : ; - the countryname ; - the 2 character countrycode ;********************************************************************** flags: copy "" ;********************************************************************** ; This field will be used as a pointer to the current flag ; and will be initialized to 1 ;********************************************************************** curflag: 1 ;********************************************************************** ; This field remembers the last find string in order to be able to ; carry on searching with the same string ;********************************************************************** findstr: copy "" ;********************************************************************** ; This field remembers the pointer to the country last found ;********************************************************************** findptr: 1 ] get-flags: func [ {Fetch countrynames and codes of all flags needed} /local countrycode countryname flaglist flags found ][ flags: copy [] parse read global/allflags [ thru "<option selected>Select a Country</option>" copy flaglist to "</select>" to end ] forever [ found: parse flaglist [ thru "geos/" copy countrycode to "." thru ">" copy countryname to "<" copy flaglist to end ] if not found [ break ] either find [ "ay" "gz" "oo" "pf" "pg" "we" "xo" "xq" "xx" "zh" zn ] countrycode [ {Due to error on website this code points to nowhere so we ignore this entry for the time being} ][ append flags reduce [ countryname countrycode ] ] ] ;********************************************************************** ; Sort the list by countryname ;********************************************************************** sort/skip flags 2 ;********************************************************************** ; Return the list of countrycodes and names implicitly ;********************************************************************** flags ] show-flags: func [ {Main program: show and search for flags} ][ view layout [ country-name: label current-country/name 600 black bold font-name font-sans-serif font-size 14 country-flag: image fetch-url across country-find: field 400 find-button: button "Find (next)" [ print "------------------------------------" print "Right after push Find (next) button:" print rejoin [ " global/findstr=(" global/findstr ")" ] print rejoin [ " country-find/text=(" country-find/text ")" ] either find-country country-find/text [ country-name/text: current-country/name country-flag/image: load fetch-url show country-name show country-flag msg-info/text: copy "" ][ msg-info/text: "Country could not be found!" ] show msg-info show country-find ] next-button: button "Next Country" [ next-country country-name/text: current-country/name country-flag/image: load fetch-url country-find/text: copy "" msg-info/text: copy "" show country-name show country-flag show country-find show msg-info ] return msg-info: info copy "" 600 yellow ] ] fetch-url: func [ {Construct the URL of the image} ][ return rejoin [ global/flagpage current-country/code "-lgflag.gif" ] ] current-country: func [ {returns either the countryname or the countrycode} /code /name ][ if code [ return pick global/flags (global/curflag + 1) ] if name [ return pick global/flags global/curflag ] ] find-country: func [ {Tries to find the country that the user suggests - a part of the name is OK} search-text /count /ptr /tmpflags ][ if search-text = "" [ return false ] either global/findstr <> search-text [ ptr: 1 ][ ptr: global/findptr + 2 ] if ptr > length? global/flags [ return false ] tmpflags: skip global/flags (ptr - 1) count: ptr foreach [ country code ] tmpflags [ if find country search-text [ global/curflag: count global/findptr: count global/findstr: search-text print "Right after a hit in find-country:" print rejoin [ " global/findstr=(" global/findstr ")" ] print rejoin [ " country-find/text=(" country-find/text ")" ] return true ] count: count + 2 ] return false ] next-country: func [ {adds 1 to country counter; if at tail, than revert to the first country} ][ global/curflag: global/curflag + 2 if tail? skip global/flags global/curflag [ global/curflag: 1 ] ] ;***********************************************************************;;; ; Main line starts here ;***********************************************************************;;; global/flags: get-flags show-flags

 [4/6] from: apwing:zonnet:nl at: 23-May-2004 16:39


Hi all, trying to solve my problem I found an error in the argument block of the find-country func. Currently it says: search-text /count /ptr /tmpflags but it should be: search-text /local count ptr tmpflags But the problem I posted for in the first place is not solved by this patch. Thanks, Arie

 [5/6] from: antonr:lexicon at: 24-May-2004 0:54


It is a lack of copy. global/findstr: copy search-text or find-country copy country-find/text Anton.

 [6/6] from: apwing::zonnet::nl at: 23-May-2004 17:44


Hi Anton, that was the old friend copy again, sigh :-[ But still I am very glad that you've made me aware of the problem :-) Many thanks for your help! Kind regards, Arie van Wingerden Anton Rolls wrote: It is a lack of copy. global/findstr: copy search-text or find-country copy country-find/text Anton. Hi all, currently I am developing a small application that displays flags from all over the world off a website. There is also a search option, in order to search for (a part of) a countryname. The REBOL/View version I use is 1.2.46.3.1. I have built in someprint statements for debugging purposes and to show the problem exactly. Example session: 1. start the app 2. fill out the search field named country-find with the text "ur" 3. click the "Find (next)" button 4. changethe contents of the search field named "country-find" to the text "ne" When you look at the displayed lines, you see (among others): Right after push Find (next) button: global/findstr=(ne) country-find/text=(ne) Apparently global/findstr has changed somewhere between the last hit and the press of the "Find (next)" button. However, there is only one place where global/findstr is being changed AFAIK! It was my intention that global/findstr would contain the PREVIOUS searchstring. Please see the attached app Any ideas? TIA With kind regards, Arie van Wingerden