mIRC Home    About    Download    Register    News    Help

Print Thread
#206761 24/11/08 11:57 PM
R
RusselB
RusselB
R
If I have an icon item in a dialog, it looks something like
Code:
  icon Canada.ico, 0 
or
Code:
  icon 21, 535 60 64 64,  RusselB.jpg, 0, noborder 


Occasionally, especially while getting others to test the script, I will forget to include the picture files, which causes mIRC to generate an error, as the file is missing.

I was wondering if there was a way of doing something like
Code:
 if $exists(Canada.ico) {
 icon Canada.ico, 0
}


NOTE: I have tried this in the dialog, and it is not liked.

I realize that I could make multiple dialog layouts depending on if the picture exists or not, but if there's an alternative I haven't thought of, I'd appreciate hearing what it is.

P
Pivo
Pivo
P
You could try using error handling to check, if the error occurs (or simply check for the files before you open the dialog), and if so, you could try to use /bwrite to create a small sample-image instead of the real one...
But thats just an idea, I don't have time to play with /bwrite and create pics now (and I'm too tired anyway) ...
I only know that this concept may fail at jpeg files due to their size, but as I said - that's all just guessed :P

Edit:
If /bwrite doesn't work for you, you could also use Picture Windows... that should do the job.
But is it worth the trouble? ...

good night...

H
Horstl
Horstl
H
Try:

icon $iif($isfile(<myicon>),<myicon>,$mircexe)

...making the default icon a stand-in

Joined: Jul 2006
Posts: 4,062
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,062
I would use something like this :
Code:
alias tryit {
  if (!$exists($1-)) .timertry -m 0 20 if ($dialog(try)) $({,0) did -h try 1 $(|) .timertry off $(},0) 
  return $iif(!$v1,$1-,$mircexe)
}
dialog try {
  title try
  size -1 -1 300 300
  option dbu
  icon 1, 10 10 10 10, $tryit(path/file.ext)
}
If the file does not exists, just use the first mirc icon file, and hide the icon as fast as possible (i use -m 0 20, because it's fine, but you can change these value)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
G
genius_at_work
genius_at_work
G
Why not use a default icon (possibly hidden) in your dialog declaration, and then change it in your onDIALOG init event? (It may not be possible to change the titlebar icon after loading.)

See the following command in the help file:

/did -g name id [n] filename


-genius_at_work

R
RusselB
RusselB
R
Your suggestion gives me an error of "Invalid table in icon"

R
RusselB
RusselB
R
Your suggestion works great for any icon item, whether in the titlebar or not.

Thanks

H
Horstl
Horstl
H
I just wanted to put the general idea in the shortest format.
Of course you get that error for dialog item definitions using $iif, due to the "," char in $iif statements, and a custom identifier bypasses this issue (Wims exteded it with the "...and hide it via timer" idea) smile

D
DJ_Sol
DJ_Sol
D
I dunno, make a start menu event that checks for the image files. If the image isn't there remove the line from the file. If you reference the id in code later you can double check the file then before executing.

D
DJ_Sol
DJ_Sol
D
hmm, I was barely awake, maybe I didn't make sense.

What I am saying is to actually remove a line from the file. The line in the dialog { event that sets the icon.

In a start event, check for the needed image, or your image folder whatever ... If it doesn't exist /write -c the line that set's the icon.

Yeah this is pretty drastic. Doesn;t offer the user the chance of downloading the proper image folder/files.



Ok .... here's another idea. Make a custom identifier for the image.


icon 21, 535 60 64 64, $image , 0, noborder


alias image {

if (image not found) { return mirc or windows .ico path (known good .ico path) }
else { return your image path }
}

R
RusselB
RusselB
R
RusselB refers DJ_Sol to Wims post in this same topic laugh

D
DJ_Sol
DJ_Sol
D
Oh did he suggest to delete the line as well? I don't really pay too much attention.

R
RusselB
RusselB
R
Not the delete line, but the alias.. which is what I'm using as it guarantees some kind of icon, even if the picture I actually wanted is missing.

D
DJ_Sol
DJ_Sol
D
If you choose no icon I believe it uses mirc's default icon anyways, doesn't it?


Link Copied to Clipboard