Page 1 of 1 1
Topic Options
#43221 - 2003-07-23 02:40 PM messagebox
lanceb2b Offline
Fresh Scripter

Registered: 2003-07-23
Posts: 8
Loc: Canada
I am using a script to do (among many other things) display a security warning message at login time, and the user will be required to click on OK to verify they are authorized to enter the system.
What my problem is, ( and I'm guessing there isn't an clear cut answer for this) depending on the users screen resolution, font size, etc... the message that I created takes on a different shape and format on each PC. What I am hoping to accomplish is to create a message box, that will look as much the same on every PC as possible.

One of the main issues is that the text that I am entering into the message, is quite long, and have entered a specific number of spaces between sentences to create what looks to be 2 paragraphs....
Here is a copy of the line I am using...

$msgbox = MESSAGEBOX("This computer system is to be used only by authorized users. By continuing to use this system, you represent that you are an authorized user and are thus subject to the terms and conditions of use. [ there are spaces here to seperate the two different languages ] Ce Systeme informatique ne peut etre utilise seulement que par des utilisateurs autorises. En utilisant ce systeme, vous affirmez etre un utilisateur autorise et etre ainsi assujetti aux termes et conditions d'usage", "WARNING!!!/AVERTISSEMENT!!!",0,0)

As I mentioned depending on the users screen resolution, and font size the characters will wrap differently on each PC. I was hoping to have the look of two paragraphs. One for English and one for French. The second paragraph will start at the far left on one PC, and it will start in the middle on the second... etc...
Is there a way to standardize how this text will look no matter what PC it is run on?
Any advise would help

[ 23. July 2003, 14:41: Message edited by: lanceb2b ]

Top
#43222 - 2003-07-23 02:47 PM Re: messagebox
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
You should be using the legal message values in the winlogon registry key. This is part of the OS.


:SetLegalMessage
; The corporate Legal Message is written to the registry. The local LAN Admins can submit
; language specific text which will be used automatically.
;
; The language specific text must have the following format. Us notepad.exe to create a text
; file. The first line will contain the text used in caption of the dialog box. The second
; line will be the entire legal message text. The ENTER key should be pressed after the second line.

If $RAS=0 and not ProductSuite("Terminal Server") ;and $VPN
Dim $String1, $String2
Dim $RC1, $RC2
Dim $RegKey
Dim $Autologon
Dim $Lang, $file

$Lang = GetUserLanguageCode()
$file = $Lpath + "\corp\legalmsg\$Lang.txt"

if OpenFile(2, $file, 2) <> 0
Writelog("Native language legal message not found: $file")
;$ErrorState set to 1 in OpenFile. Reset $ErrorState to 0 as not to display the error notification.
$ErrorState = 0
$file = $Lpath + "\corp\legalmsg\0409.txt"

if OpenFile(2, $file, 2) <> 0
Writelog("Error: Legal text not found. " + $file)
endif
endif

$String1 = Readline(2)
$String2 = Readline(2)
$RC1 = close(2)

Select
Case $OS="WinNT"
$RegKey="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon"
Case $OS="Win9x"
$RegKey="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\winlogon"
EndSelect

; The legal message interferes with the autologon process and therefore will not be installed
; on computers configured for autologon.

$Autologon=ReadValue("$RegKey","AutoAdminLogon")
if @error = 2
$Autologon=0
endif
If $Autologon=0
$RC1=WriteValue($RegKey,"LegalNoticeCaption",$String1,"REG_SZ")
$RC2=WriteValue($RegKey,"LegalNoticeText",$String2,"REG_SZ")
if $RC1=0 and $RC2=0
WriteLog ("Wrote legal message to registry.")
else
WriteLog ("Error writing Legal Message: LegalNoticeCaption error=$RC1, LegalNoticeText error=$RC2")
if $RC1<>5
$ErrorState=1
endif
endif
Else
WriteLog ("Legal Message skipped because computer is configured for AutoLogon.")
Endif

If $OS="WinNT"
$RC=WriteValue($RegKey,"RunLogonScriptSync","1","REG_DWORD")
Endif
Endif
Return


Note that you need Admin writes to create or write to these location on an NT or higher OS computer. In that case, the message should be part of the build process.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#43223 - 2003-07-23 02:50 PM Re: messagebox
lanceb2b Offline
Fresh Scripter

Registered: 2003-07-23
Posts: 8
Loc: Canada
Thanks for the reply, and I was aware of this registry entry, however, because of internal logistics, and opinions, they have decided against entering this message on each PC locally, and want this run after login time only, and only if a succesfull login is achieved......
Top
#43224 - 2003-07-23 03:08 PM Re: messagebox
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You can use @CRLF to create paragraphs. However, the final layout is descided by the user's desktop settings, e.g. screen resolution, font sizes, and so on. Thus, you cannot create a identical-looking messagebox unless you standardize teh desktop look-and-feel. Be advised that the messagebox is limited to a total of 1024 characters.
code:
$warning='the english text'+@CRLF+@CRLF+'the franco-canadian text'
$rc=messagebox($warning,'english - franco-canadian')



[ 23. July 2003, 15:09: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#43225 - 2003-07-23 03:40 PM Re: messagebox
lanceb2b Offline
Fresh Scripter

Registered: 2003-07-23
Posts: 8
Loc: Canada
What is the correct way to use the @CRLF macro....
I tried using it the way you posted it, but It returns
Top
#43226 - 2003-07-23 03:44 PM Re: messagebox
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
quote:
It returns
It returns what? Please clarify the problem.
_________________________
There are two types of vessels, submarines and targets.

Top
#43227 - 2003-07-23 03:52 PM Re: messagebox
lanceb2b Offline
Fresh Scripter

Registered: 2003-07-23
Posts: 8
Loc: Canada
sorryh, I don't know why it didn't post.... oopsie

it returned
unknown:CRLF unknown:CRLF in place of the 2 @CRLF entries which I was hoping would put Carraige returns

My code looked like this

$wrnmsg = "Canadian text"+@CRLF+@CRLF+"french text"
$messsage = MESSAGEBOX($wrnmsg,"WARNING/AVERTISSEMENT",0,0)

Top
#43228 - 2003-07-23 05:34 PM Re: messagebox
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might run an old version of KiXtart. The current release is KiXtart v4.21 and @CRLF is available since KiXtart 4.01 RC4.
_________________________
There are two types of vessels, submarines and targets.

Top
#43229 - 2003-07-23 05:55 PM Re: messagebox
lanceb2b Offline
Fresh Scripter

Registered: 2003-07-23
Posts: 8
Loc: Canada
thanks for the tip. I am currently on 3.61 he he
will try and let you know

THANKS!

Top
#43230 - 2003-07-23 06:11 PM Re: messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I am a great advocate of using the latest and greatest, but if you need the functionality in 3.xx, just use Chr(13) and/or Chr(10).
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#43231 - 2003-07-23 06:16 PM Re: messagebox
lanceb2b Offline
Fresh Scripter

Registered: 2003-07-23
Posts: 8
Loc: Canada
what will the CHR(13) and CHR(10) do?

IS it to emulate a character on a keyboard?

I have put in Ver 4.21 and so far no glitches, and the @CRLF works... Hopefully a few days of testing will turn up any kinks....

[ 23. July 2003, 18:18: Message edited by: lanceb2b ]

Top
#43232 - 2003-07-23 06:19 PM Re: messagebox
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
CHR(10) and CHR(13) are the ASCII-representations of the 'carriage return' and the 'line feed' characters that combined will result in a cursor to be in the first column of the follwing row.

You might want to let other's know the KiXtart version you are using as the answers will depend on it. For example, KiXtart 3.x does not support UDFs.
_________________________
There are two types of vessels, submarines and targets.

Top
#43233 - 2003-07-23 06:22 PM Re: messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Or you could just lookup CHR() in the manual.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#43234 - 2003-07-23 06:24 PM Re: messagebox
lanceb2b Offline
Fresh Scripter

Registered: 2003-07-23
Posts: 8
Loc: Canada
I did look up CHR () in the manual after I posted ( I know I should have checked first) but it did not tell me what (10) and (13) represented....

Thanks for the help....

Top
#43235 - 2003-07-23 06:28 PM Re: messagebox
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
All I am trying to say is that the manual is your friend, not slamming you with RTFM.

In the ScriptLogic CHM version at least, it has a self-explanitory example.
quote:
Chr( )

Action: Insert special characters, such as carriage returns, in a string.

Syntax: Chr (character code)

Parameters: Character code
A numeric expression representing the character code to insert.

Returns: The string representation of the character code.

See Also: Asc( )

Example: $Message= "Hello " + @USERID + chr(13) + chr(10) + "Welcome to our network."



You could also cobble together a test script to see what it does. IMHO, it is the best way to learn.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#43236 - 2003-07-23 08:07 PM Re: messagebox
lanceb2b Offline
Fresh Scripter

Registered: 2003-07-23
Posts: 8
Loc: Canada
I completely understand what you mean about learning yourself.... I wasn't taking what you said as a dig.....
i suppose I could have tested to see what the CHR(10) and(13) did, but really I would have just seen that it did what I wanted it to, but not know how it did it... As you posted, the explaination of the command explains that it will insert a chcaracter code, but wasn't sure what 10 and 13 were... I didn't see a list of what the character codes were...

But thanks again for your help, and I will promise :-) (for you guys and me) to do my own research first....
[Razz]

Top
#43237 - 2003-07-23 08:09 PM Re: messagebox
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Chr() codes can be found at http://www.asciitable.com or in a MS-Access installation too.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#43238 - 2003-07-24 11:05 AM Re: messagebox
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
chr(10) is "line feed" (LF)
chr(13) is "carriage return" (CR)

this is why the kix macro is called crlf
theses two characters are usually used as the end of line in text files on Microsoft OS.

on Unix, the end of line character is LF

example for messagebox with kix 3.6x

$crlf = chr(13)+chr(10)
$=messagebox(
"the first line"+$crlf+
"the second line"+$crlf+
$crlf+
"the last line",
"the title,
0
)
_________________________
Christophe

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 811 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.142 seconds in which 0.076 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org