Credizian


I am going crazy trying to figure out a way to change an Abbreviated State name to its full form...because Facebook usually outputs the abbreviated version and Geo doesn't use the abbreviated form.

i have been working on the code from another block that does the switching thing (don't want to disclose the name) only to realize now that it actually doesn't work itself...which completely throws off everything I am doing to it by trying to understand its code because I don't know how to code myself.

I will go ahead and share my block called "State Ab Expand" if someone can help that would be awesome.

Thanks.

Keshav





Re: Help!

AndyS


Hi you weren't that far off :-). I created a block and shared it that does what you want you can find it at: http://www.popfly.ms/users/Andy/Stand%20Abrv%20to%20Name.details

Because of the way you choose to store the state names the code to lookup the state name is simple Smile, The most important change to make was adding a toString and changing the call mode to sync from async.

The function itself looks like:


Code Block

AbExpand.prototype.expand = function(text)
{
this.State = encmap[text];
return this.State;
};



Hope that helps! Smile





Re: Help!

DonG2

Howdy Keshav,

Last Wednesday I ripped your State Ab Expand block and spent several days trying to figure out why it wasn't working (I mentioned in another thread that I might give it a go). For the life of me, I could NOT get the block to return a string or object value. I even created a simple test block to find out why no value was being returned, but it wouldn't return a value either! So I finally posted a message here in the forums, but it hasn't been answered yet.

Sorry I couldn't figure it out and help you Sad.

Andy: After looking at the changes you made to this block, I have a couple of questions...

Q1: I've not been able to find any documentation or other topics here in the forum regarding CallMode. What values are allowed, besides sync and async What are their purposes / differences When should each be used

Q2: I'm new to Javascript, so I don't understand how the "var encmap = {...};" statement that defines the array ever gets executed, since it's not inside a function. Is all JS code executed from top to bottom regardless of whether or not it's contained in a function definition

Thanks for your help Andy Smile!







Re: Help!

DonG2

For anyone who wants to convert a 2-letter USA State abbreviation to the full name of the State, I just shared a new block that does this. Here's a link to the topic describing it: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2213625&SiteID=1






Re: Help!

Credizian

Thanks a lot!!! It worked but now I am facing another problem...take a look when you got some free time that you wanna donate Big Smile

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2216054&SiteID=1&mode=1

Keshav






Re: Help!

DonG2

You're welcome Keshav Smile. I've been wanting to get this going ever since I first tried using GeoNames with a state abbreviation. You having the same problem encouraged me to try.

Since I'm a new member of Facebook, I don't have 26+ friends to check your mashup with. Is the Show Console display not providing you with data for each step it executes in the mashup ... with an Error where it stops






Re: Help!

Credizian

well when you are working within the create mashup, you don't get to see your own data, you can only see it once you view in a separate window, so I don't know what is wrong with my data and where its messing up on it.

but it does seem to work with the default data provided during mashup creation in preview mode. try it out...I have the mashup shared.






Re: Help!

DonG2

I did try it, but since I only have 3 friends on Facebook, all in the same city, only one pushpin shows up. So, I don't know if all 3 are actually there or not <sigh>. Set me (Don Goyette - Calhan, CO) as a friend in Facebook and then we'll be able to see if multiple pushpins show up or not. I've requested a couple of other friendships but they haven't approved yet.






Re: Help!

Credizian

So u tried to view the mashup with ur facebook api in it, in an outside browser and it actually worked showing at least one pushpin in the right place. Okay so either I got too many friends (just sayin...I really don't have that many Smile ) and its erroring out somewhere, or there is just some other problem.

btw I added you. See if it shows me on your map.

Keshav






Re: Help!

DonG2

Howdy Keshav,

Thank you, yes you show up on the map Smile.

However, if you have multiple friends in the same city, all pushpins or thumbnail images are "stacked" one on top of the other, with only the last one added showing Sad.

The ConvertState block was written with a single abbreviation-to-state conversion in mind, so it was returning an error when the abbr was blank, like many entries on Facebook are (no city or state).

So, I just added a second Input field (Quantity) which will allow the code to either report an error, when an abbr is not sent, for a SINGLE conversion --OR-- send back a blank string, for MULTIPLE conversions. The latter is what your mashup required, so now it should work properly.

The updated block is shared in my projects and is named ConvertState_0-4_beta.

Let me know how it goes!






Re: Help!

Credizian

Okay so I tried to apply the new block but everytime it tells me that there is an xml error with the block so it won't let me add it...

Man i really need to get going on learning the java and xml...i hate you wasting your time on this...and I not being able to help.

Thanks for everything!






Re: Help!

Credizian

btw I also tried changing the pushpin to thumbnails...right now its at thumbnails...and it still won't display my stuff...gah!!!

Developers, if you are reading this, is it possible for me to share my API Key for facebook with you and you try it out and see why its not working...It works for DonG but not for me ! !

Thanks.






Re: Help!

DonG2

Howdy Keshav,

That is so bizarre! It was working fine this afternoon, and now it won't even place itself into a mashup ! Sheesh!

After trying many different things, it appears that in the Block Description (XML) code, there is a limit on the length of multi-line comments, which start with "<!--" and end with "-->" Sad. When I deleted several lines of the opening comment, the block then loaded into a mashup without error. Why in the world it worked this afternoon and not tonight, is beyond me. That subject is for another forum thread.

So, try it again please. In order to not confuse folks, I copied the modified code to the original block file: "ConvertState", and deleted the "ConvertState_0-4_beta" version of the block.

Sorry for the problems. We do need to remember that Popfly IS an Alpha test product, which means that sometimes things don't work as we might expect them to Smile. And, this creating a block stuff is new to me. No worries about my time, as that's the only thing I have plenty of <LOL>!

Now if we could just get our DSL connection to run faster than a dial-up modem, I'd be a much happier camper than I am right now. It appears that our ISP has over-sold and over-connected customers to their DSL lines, making for very slow connect speeds Sad. But that's my problem ...