What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Loading a external image

Loading a external image
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: Loading a external image
quote:
Originally posted by Mattike
quote:
Originally posted by CookieRevised
Short answer: declare WndProfileInformation as a global variable.
And this should be done when you create the window, like in:
code:
WndProfileInformation = MsgPlus.CreateWnd("thing.xml", "WndProfileInformation");
The difference here is the missing "var" prefix, without it it'll get declared as a global variable.

Note: when the window is destroyed, you should delete the variable too!

Personally I would not recommend declaring variables like that. It is bad practice and prone to errors/bugs if you're not carefull.

Always use var and always declare your global variables outside functions first.


quote:
Originally posted by Yorick
I want to show some information, but I don't always have all the information....

Like this:
Profile:
Name
Country (optional)
Age (Optional)

But sometimes I don't have information to fill the country, and I do have information to fill the age. If I do it with static controls, you'll get a gap, because I can't fill country.. anyone a brilliant idea how to do this?
we need far more information to answer this question properly as there are billions of things which you can mean or want to do.


With the information given all I can say is if you don't have the info then don't display it and use a description prefix.
eg:
Profile
    Name: John
    Country:
    Age: 25



EDIT: after seeing your other thread, I understand what you mean. hint: always provide enough details from the start ;)

PS: a control is in that context always static... no control moves around on their own. Static means 'user can not interact with it' (eg: a text label), opposed to dynamic which is changeable by the user (eg: a combobox). Thus it doesn't have anything todo with moving.


Anyways,

Or you could simply move controls, but this will require the use of Windows APIs. This is possible, but certainly not elegant for this purpose.

Or you could instead of making 3 static labels, just make 1 static label and fill it with a string which is a concatenation from the individual variables seperated with a newline character (\n).

eg:
code:
var Name = "John";
var Country = "";
var Age = "25";
var ShoeSize = "5";
var Fingers = "10"
var State = "Married";

var Profile  = ""; // String to display in first and only label control

If (Name !== "") Profile += "\n" + Name;
If (Country !== "") Profile += "\n" + Country;
if (Age !== "") Profile += "\n" + Age + (Age == 1 ? " year" : " years");
if (ShoeSize !== "") Profile += "\n" + ShoeSize;
if (Fingers !== "") Profile += "\n" + Fingers;
if (Sate !== "") Profile += "\n" + State;

// Remove first NewLine character
Profile = Profile.substr(1);

// Set control text
wndProfileWindow.SetControlText("lblProfile", Profile);
PS: Also notice what I've done with the age. That line adds either "years" or "year" according to what the age is (if age is 1 it will add "year"; thus without the s).

(Age == 1 ? " year" : " years") is called a ternary operation. It is in fact an IF THEN ELSE but written as a single statement on one line. The shown ternary operation is the same as if you would write:
code:
if (Age == 1) {
    return " year"
}
else {
    return " years"
}

This post was edited on 03-03-2007 at 01:49 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-02-2007 09:13 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Loading a external image - by Yorick on 03-01-2007 at 05:00 PM
RE: Loading a external image - by Matti on 03-01-2007 at 05:24 PM
RE: Loading a external image - by matty on 03-01-2007 at 06:03 PM
RE: Loading a external image - by Yorick on 03-02-2007 at 06:53 PM
RE: Loading a external image - by CookieRevised on 03-02-2007 at 07:01 PM
RE: Loading a external image - by Yorick on 03-02-2007 at 07:04 PM
RE: Loading a external image - by Matti on 03-02-2007 at 07:23 PM
RE: RE: Loading a external image - by CookieRevised on 03-02-2007 at 09:13 PM
RE: Loading a external image - by Yorick on 03-02-2007 at 07:32 PM
RE: RE: RE: Loading a external image - by Eljay on 03-02-2007 at 09:23 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On