Recent Posts

Pages: 1 ... 7 8 [9] 10
81
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by John on December 29, 2019, 05:03:15 AM »
I agree that one should be able to hit the return key to tab from User ID to Password and to the login button.
82
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by John on December 28, 2019, 08:18:56 PM »
That worked.

Thanks.

I'm spoiled by SB not having to declare anything.
83
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by AIR on December 28, 2019, 07:44:51 PM »
AIR,

Do you know how to  make Nim variables global?

It says it can find uidtxt in the callback.

You have to declare them before the call to Open(), removing the 'let' from the declared variables.  You can either declare them before the callback, or forward declare the callback and move it to the end of the code.

Something like:

Code: Text
  1. import niup
  2. import niupext
  3.  
  4. var uidtxt,showpwd,pwdtxt1,pwdtxt2,errlbl:PIhandle
  5. proc login_clicked(ih:PIhandle):cint {.cdecl.}
  6.  
  7. Open()
  8.  
  9. # *** DIALOG ***
  10. let dlg = Create("dialog")
  11. SetAttributes(dlg,
  12.   "TITLE=\"Login\", " &
  13.   "SIZE=200x200, " &
  14.   "MAXBOX=NO, " &
  15.   "MINBOX=NO, " &
  16.   "RESIZE=NO")
  17.  
  18. # *** CONTAINER ***
  19. let vb = Create("vbox")
  20.  
  21. # *** IMAGE ***
  22. let hb1 = Create("hbox")
  23. let piclbl = Create("label")
  24. SetAttributes(piclbl,  
  25.   "IMAGE=\"login.png\", " &
  26.   "EXPAND=HORIZONTAL, " &
  27.   "ALIGNMENT=ACENTER:ATOP")
  28. discard Append(hb1, piclbl)
  29. discard Append(vb, hb1)
  30.  
  31. # *** ERROR ***
  32. let hb2 = Create("hbox")
  33. errlbl = Create("label")
  34. SetAttributes(errlbl,
  35.   "TITLE=\"User ID / Password Incorrect\", " &
  36.   "FGCOLOR=\"#ff0000\", " &
  37.   "EXPAND=HORIZONTAL, " &
  38.   "ALIGNMENT=ACENTER")
  39. # Hide(errlbl)
  40. discard Append(hb2, errlbl)
  41. discard Append(vb, hb2)
  42.  
  43. # *** ENTRY ***
  44. let hb3 = Create("hbox")
  45. SetAttributes(hb3,
  46.   "MARGIN=20x10, " &
  47.   "GAP=5")
  48. let vb1 = Create("vbox")
  49. SetAttribute(vb1, "GAP", "15")
  50. let uidlbl = Create("label")
  51. SetAttribute(uidlbl, "TITLE", "User ID")
  52. discard Append(vb1, uidlbl)
  53. let pwdlbl = Create("label")
  54. SetAttribute(pwdlbl, "TITLE", "Password")
  55. discard Append(vb1, pwdlbl)
  56. discard Append(hb3, vb1)
  57. let vb2 = Create("vbox")
  58. uidtxt = Create("text")
  59. SetAttribute(uidtxt, "SIZE", "85x")
  60. discard Append(vb2, uidtxt)
  61. pwdtxt1 = Create("text")
  62. SetAttributes(pwdtxt1,
  63.   "PASSWORD=YES, " &
  64.   "SIZE=85x")
  65. pwdtxt2 = Create("text")
  66. SetAttribute(pwdtxt2, "SIZE", "85x")
  67. SetHandle("pwdtxt1", pwdtxt1)
  68. SetHandle("pwdtxt2", pwdtxt2)
  69. let zbtxt = Zbox(pwdtxt1, pwdtxt2, nil)
  70. SetHandle("zbtxt", zbtxt)
  71. discard Append(vb2, zbtxt)
  72. discard Append(hb3, vb2)
  73. discard Append(vb, hb3)
  74.  
  75. # *** SHOW/HIDE ***
  76. let hb4 = Create("hbox")
  77. SetAttribute(hb4, "MARGIN", "35x")
  78. showpwd = Create("toggle")
  79. SetAttributes(showpwd,
  80.   "TITLE=\"Show Password?\", " &
  81.   "CANFOCUS=NO")
  82. discard Append(hb4, showpwd)
  83. discard Append(vb, hb4)
  84.  
  85. # *** LOGIN ***
  86. let hb5 = Create("hbox")
  87. SetAttribute(hb5, "MARGIN", "40x10")
  88. let loginbut = Create("button")
  89. SetAttributes(loginbut,
  90.   "TITLE=\"Login\", " &
  91.   "EXPAND=HORIZONTAL")
  92. discard Append(hb5, loginbut)
  93. discard Append(vb, hb5)
  94.  
  95. # *** ATTACH CONTAINER ***
  96. discard Append(dlg, vb)
  97.  
  98. # *** CALLBACKS ***
  99. SetCallback(loginbut, "ACTION", login_clicked)
  100. #~ SetCallback(showpwd, "ACTION", show_password)
  101.  
  102. # *** PROCESS ***
  103. Show(dlg)
  104. MainLoop()
  105. Close()
  106.  
  107. proc login_clicked(ih:PIhandle):cint {.cdecl.} =
  108.   var pwd:cstring
  109.   let uid = GetAttribute(uidtxt,"VALUE")
  110.   if GetAttribute(showpwd, "VALUE") == "OFF":
  111.     pwd = GetAttribute(pwdtxt1,"VALUE")
  112.   else:
  113.     pwd = GetAttribute(pwdtxt2,"VALUE")
  114.  
  115.   if uid == "John" and pwd == "Spikowski":
  116.     Hide(errlbl)
  117.     Message("Login",  "Login Successful")
  118.     return IUP_CLOSE
  119.   else:
  120.     Show(errlbl)
  121.     SetFocus(uidtxt)
  122.  
  123.  

Nim has a '{.global.}' pragma, but it essentially functions like the 'static' keyword does in C.  Won't work in this case, because it looks like the call to 'Open' sets up a proc so the variables are local to that but 'static' as in C.


84
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by AIR on December 28, 2019, 06:37:54 PM »
If we're going to add toggling the visibility of the password as a 'requirement', we should also add the password box reacting to the "Enter/Return" key.

Code: C
  1. /* logon2.c
  2.  *
  3.  * version 1.2
  4.  *
  5.  * GUI Logon Screen Challenge Submission
  6.  * C version, using GTK+-3.0
  7.  *
  8.  * Written by Armando I. Rivera (AIR)
  9.  *
  10.  * Compile:  gcc logon2.c $(pkg-config --libs --cflags gtk+-3.0) -o logon2
  11. */
  12.  
  13. #include <gtk/gtk.h>
  14.  
  15. GtkWidget *err_label;
  16.  
  17. void chkBox_cb (GtkToggleButton *toggle_button, gpointer data) {
  18.       if (gtk_toggle_button_get_active (toggle_button)) {
  19.           g_object_set(data,"visibility",TRUE,NULL);
  20.       }else{
  21.           g_object_set(data,"visibility",FALSE,NULL);
  22.       }
  23. }
  24.  
  25. void txtPass_cb( GtkWidget *widget, gpointer data ) {
  26.     g_object_set(data,"label","",NULL);
  27. }
  28.  
  29. void onClick( GtkWidget *widget, gpointer data ) {
  30.     gchar *stupid_password = "pa$$w0rd!";
  31.     gchar *user_password;
  32.     g_object_get(data,"text",&user_password,NULL);
  33.  
  34.     if (g_strcmp0 (stupid_password,user_password) == 0) {
  35.         g_print("Your are now logged in!\n");
  36.         gtk_main_quit();
  37.     }else{
  38.         gtk_label_set_markup(GTK_LABEL(err_label), "<span color=\"red\" font_desc=\"16.0\">** Invalid Password **</span>");
  39.         g_print("Username or Password is Incorrect!\n");
  40.  
  41.     }
  42. }
  43.  
  44. int main( int argc, char *argv[])
  45. {
  46.     GtkWidget *window, *layout, *image, *btnLogin, *chkBox;
  47.     GtkWidget *lblUser, *lblPass, *txtUser, *txtPass;
  48.  
  49.     gtk_init(&argc, &argv);
  50.    
  51.     layout = gtk_layout_new(NULL, NULL);
  52.  
  53.     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  54.     g_object_set(window,
  55.                 "title","Login",
  56.                 "default-width",660,
  57.                 "default-height",370,
  58.                 "resizable",FALSE,
  59.                 "window-position",GTK_WIN_POS_CENTER,
  60.                 "child",layout,
  61.                 "decorated",0,
  62.                 NULL);
  63.  
  64.  
  65.     image = gtk_image_new_from_file("logon.png");
  66.     g_object_set(layout,"child",image,"margin",10,NULL);
  67.    
  68.     lblUser = gtk_label_new("");
  69.     lblPass = gtk_label_new("");
  70.     err_label = gtk_label_new("");
  71.     g_object_set(err_label,"width-request",270,NULL);
  72.    
  73.     gtk_label_set_markup(GTK_LABEL(lblUser), "<span font_desc=\"16.0\">Username:</span>");
  74.     gtk_label_set_markup(GTK_LABEL(lblPass), "<span font_desc=\"16.0\">Password:</span>");
  75.    
  76.     txtUser = gtk_entry_new();
  77.     txtPass = gtk_entry_new();    
  78.     g_object_set(txtPass,"visibility", FALSE,NULL);
  79.    
  80.     chkBox = gtk_check_button_new_with_label("Show Password");
  81.  
  82.     btnLogin = gtk_button_new_with_label("Login");
  83.     g_object_set(btnLogin,"width-request",170,NULL);
  84.  
  85.  
  86.     gtk_layout_put(GTK_LAYOUT(layout), lblUser, 330, 112-30);
  87.     gtk_layout_put(GTK_LAYOUT(layout), lblPass, 330, 162-30);
  88.     gtk_layout_put(GTK_LAYOUT(layout), txtUser, 460, 110-30);
  89.     gtk_layout_put(GTK_LAYOUT(layout), txtPass, 460, 160-30);
  90.     gtk_layout_put(GTK_LAYOUT(layout), chkBox, 460, 210-30);
  91.     gtk_layout_put(GTK_LAYOUT(layout), btnLogin, 460, 250-30);
  92.     gtk_layout_put(GTK_LAYOUT(layout), err_label, 300, 16);
  93.  
  94.     g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  95.     g_signal_connect (btnLogin, "clicked", G_CALLBACK (onClick), txtPass);
  96.     g_signal_connect (chkBox, "toggled", G_CALLBACK (chkBox_cb), txtPass);
  97.     g_signal_connect (txtPass, "changed", G_CALLBACK (txtPass_cb), err_label);
  98.     g_signal_connect (txtPass, "activate", G_CALLBACK (onClick), txtPass);
  99.    
  100.     gtk_widget_show_all(window);
  101.  
  102.     gtk_main();
  103.  
  104.     return 0;
  105. }
  106.  
  107.  
  108.  

AIR.
85
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by John on December 28, 2019, 06:36:46 PM »
AIR,

Do you know how to  make Nim variables global?

It says it can find uidtxt in the callback.

Code: Text
  1. import niup
  2. import niupext
  3.  
  4. proc login_clicked(ih:PIhandle):cint {.cdecl.}=
  5.   let uid = GetAttribute(uidtxt,"VALUE")
  6.   if GetAttribute(showpwd, "VALUE") == "OFF":
  7.     let pwd = GetAttribute(pwdtxt1,"VALUE")
  8.   else:
  9.     let pwd = GetAttribute(pwdtxt2,"VALUE")
  10.  
  11.   if uid == "John" and pwd == "Spikowski":
  12.     Hide(errlbl)
  13.     Message("Login",  "Login Successful")
  14.     return IUP_CLOSE
  15.   else:
  16.     Show(errlbl)
  17.     SetFocus(uidtxt)
  18.  
  19. Open()
  20.  
  21. # *** DIALOG ***
  22. let dlg = Create("dialog")
  23. SetAttributes(dlg,
  24.   "TITLE=\"Login\", " &
  25.   "SIZE=200x200, " &
  26.   "MAXBOX=NO, " &
  27.   "MINBOX=NO, " &
  28.   "RESIZE=NO")
  29.  
  30. # *** CONTAINER ***
  31. let vb = Create("vbox")
  32.  
  33. # *** IMAGE ***
  34. let hb1 = Create("hbox")
  35. let piclbl = Create("label")
  36. SetAttributes(piclbl,  
  37.   "IMAGE=\"login.png\", " &
  38.   "EXPAND=HORIZONTAL, " &
  39.   "ALIGNMENT=ACENTER:ATOP")
  40. discard Append(hb1, piclbl)
  41. discard Append(vb, hb1)
  42.  
  43. # *** ERROR ***
  44. let hb2 = Create("hbox")
  45. let errlbl = Create("label")
  46. SetAttributes(errlbl,
  47.   "TITLE=\"User ID / Password Incorrect\", " &
  48.   "FGCOLOR=\"#ff0000\", " &
  49.   "EXPAND=HORIZONTAL, " &
  50.   "ALIGNMENT=ACENTER")
  51. # Hide(errlbl)
  52. discard Append(hb2, errlbl)
  53. discard Append(vb, hb2)
  54.  
  55. # *** ENTRY ***
  56. let hb3 = Create("hbox")
  57. SetAttributes(hb3,
  58.   "MARGIN=20x10, " &
  59.   "GAP=5")
  60. let vb1 = Create("vbox")
  61. SetAttribute(vb1, "GAP", "15")
  62. let uidlbl = Create("label")
  63. SetAttribute(uidlbl, "TITLE", "User ID")
  64. discard Append(vb1, uidlbl)
  65. let pwdlbl = Create("label")
  66. SetAttribute(pwdlbl, "TITLE", "Password")
  67. discard Append(vb1, pwdlbl)
  68. discard Append(hb3, vb1)
  69. let vb2 = Create("vbox")
  70. let uidtxt = Create("text")
  71. SetAttribute(uidtxt, "SIZE", "85x")
  72. discard Append(vb2, uidtxt)
  73. let pwdtxt1 = Create("text")
  74. SetAttributes(pwdtxt1,
  75.   "PASSWORD=YES, " &
  76.   "SIZE=85x")
  77. let pwdtxt2 = Create("text")
  78. SetAttribute(pwdtxt2, "SIZE", "85x")
  79. SetHandle("pwdtxt1", pwdtxt1)
  80. SetHandle("pwdtxt2", pwdtxt2)
  81. let zbtxt = Zbox(pwdtxt1, pwdtxt2, nil)
  82. SetHandle("zbtxt", zbtxt)
  83. discard Append(vb2, zbtxt)
  84. discard Append(hb3, vb2)
  85. discard Append(vb, hb3)
  86.  
  87. # *** SHOW/HIDE ***
  88. let hb4 = Create("hbox")
  89. SetAttribute(hb4, "MARGIN", "35x")
  90. let showpwd = Create("toggle")
  91. SetAttributes(showpwd,
  92.   "TITLE=\"Show Password?\", " &
  93.   "CANFOCUS=NO")
  94. discard Append(hb4, showpwd)
  95. discard Append(vb, hb4)
  96.  
  97. # *** LOGIN ***
  98. let hb5 = Create("hbox")
  99. SetAttribute(hb5, "MARGIN", "40x10")
  100. let loginbut = Create("button")
  101. SetAttributes(loginbut,
  102.   "TITLE=\"Login\", " &
  103.   "EXPAND=HORIZONTAL")
  104. discard Append(hb5, loginbut)
  105. discard Append(vb, hb5)
  106.  
  107. # *** ATTACH CONTAINER ***
  108. discard Append(dlg, vb)
  109.  
  110. ' *** CALLBACKS ***
  111. SetCallback(loginbut, "ACTION", login_clicked)
  112. SetCallback(showpwd, "ACTION", show_password)
  113.  
  114. # *** PROCESS ***
  115. Show(dlg)
  116. MainLoop()
  117. Close()
  118.  
86
Toolbox / The Hex Editor for Windows in QB64
« Last post by eoredson on December 28, 2019, 12:49:31 AM »
The Hex Editor for Windows v8.0a r5.0a.

Allows fast file editing in a hexidecimal window environment.

Includes 32-bit QB64 BASIC Source Code public domain 2017.

Author: Erik Jon Oredson, Email: eoredson@gmail.com
87
Interpreters / The Symbolic Instruction Code Interpreter
« Last post by eoredson on December 28, 2019, 12:41:40 AM »
Symbolic Instruction Code Kit (S.I.C.K.)

Author: Erik Jon Oredson (alias: eoredson) (eoredson@gmail.com)
Source: qb64.net Forum
URL: https://www.qb64.org/forum/index.php?topic=198.0
Version: SICK64D3 (2019)
Tags: [interpreter]

Description:
The Symbolic Instruction Code Kit, which contains a QB64 program named SIC64.BAS
and several smaller utility programs. The source code is public domain and can be
found on several sites, including, www.filegate.net and www.keepandshare.com

This program uses a recursive descent parser to interpret a psuedo-basic language
written in a line number oriented fashion and can be used for small programming chores.

The archive also contains some further imbedded .zip files which contain several
QB64 sample programs, and some .SIC programs which are used by the SIC engine.

Source Code:
See download(s) below, or follow this link: https://bit.ly/EriksSICK
88
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by John on December 27, 2019, 09:50:39 PM »
It would be great to make the password hide/show as part of the challenge requirements. It's an interesting twist.
89
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by John on December 27, 2019, 08:36:50 PM »
I was able to get the show/hide password working correctly.

If you want to  give this a try, I attached everything you need to do so.

Code: Script BASIC
  1. ' ScriptBasic / IUP - Login - JRS
  2.  
  3. IMPORT iup.bas
  4.  
  5. SUB login_clicked
  6.   uid = Iup::GetAttribute(uidtxt,"VALUE")
  7.   IF Iup::GetAttribute(showpwd, "VALUE") = "OFF" THEN
  8.     pwd = Iup::GetAttribute(pwdtxt1,"VALUE")
  9.   ELSE
  10.     pwd = Iup::GetAttribute(pwdtxt2,"VALUE")
  11.   END IF
  12.   IF uid = "John" AND pwd = "Spikowski" THEN
  13.     Iup::Hide(errlbl)
  14.     Iup::Message("Login",  "Login Successful")
  15.     Iup::ExitLoop = TRUE
  16.   ELSE
  17.     Iup::Show(errlbl)
  18.     Iup::SetFocus(uidtxt)
  19.   END IF
  20. END SUB
  21.  
  22. SUB show_password
  23.   showcb = Iup::GetAttribute(showpwd, "VALUE")
  24.   IF showcb = "OFF" THEN
  25.     pwd2 = Iup::GetAttribute(pwdtxt2,"VALUE")
  26.     Iup::SetAttribute(pwdtxt1, "VALUE", pwd2)
  27.     Iup::SetAttribute(zbtxt, "VALUE", "pwdtxt1")
  28.   ELSE
  29.     pwd1 = Iup::GetAttribute(pwdtxt1,"VALUE")
  30.     Iup::SetAttribute(pwdtxt2, "VALUE", pwd1)
  31.     Iup::SetAttribute(zbtxt, "VALUE", "pwdtxt2")
  32.   END IF
  33. END SUB
  34.  
  35. SUB Win_exit
  36.   Iup::ExitLoop = TRUE
  37. END SUB
  38.  
  39. Iup::Open()
  40. dlg = Iup::Create("dialog")
  41. Iup::SetAttributes(dlg, "TITLE=\"Login\", SIZE=200x200")
  42.  
  43. vb = Iup::Create("vbox")
  44. hb1 = Iup::Create("hbox")
  45. piclbl = Iup::Create("label")
  46. Iup::SetAttribute(piclbl, "IMAGE", "./login.png")
  47. Iup::SetAttribute(piclbl, "EXPAND", "HORIZONTAL")
  48. Iup::SetAttribute(piclbl, "ALIGNMENT", "ACENTER:ATOP")
  49. Iup::Append(hb1, piclbl)
  50. Iup::Append(vb, hb1)
  51.  
  52. hb2 = Iup::Create("hbox")
  53. errlbl = Iup::Create("label")
  54. Iup::SetAttribute(errlbl, "TITLE", "User ID / Password Incorrect")
  55. Iup::SetAttribute(errlbl, "FGCOLOR", "#ff0000")
  56. Iup::SetAttribute(errlbl, "EXPAND", "HORIZONTAL")
  57. Iup::SetAttribute(errlbl, "ALIGNMENT", "ACENTER")
  58. Iup::Hide(errlbl)
  59. Iup::Append(hb2, errlbl)
  60. Iup::Append(vb, hb2)
  61.  
  62. hb3 = Iup::Create("hbox")
  63. Iup::SetAttribute(hb3, "MARGIN", "20x10")
  64. Iup::SetAttribute(hb3, "GAP", "5")
  65. vb1 = Iup::Create("vbox")
  66. Iup::SetAttribute(vb1, "GAP", "15")
  67. uidlbl = Iup::Create("label")
  68. Iup::SetAttribute(uidlbl, "TITLE", "User ID")
  69. Iup::Append(vb1, uidlbl)
  70. pwdlbl = Iup::Create("label")
  71. Iup::SetAttribute(pwdlbl, "TITLE", "Password")
  72. Iup::Append(vb1, pwdlbl)
  73. Iup::Append(hb3, vb1)
  74. vb2 = Iup::Create("vbox")
  75. uidtxt = Iup::Create("text")
  76. Iup::SetAttribute(uidtxt, "SIZE", "85x")
  77. Iup::Append(vb2, uidtxt)
  78. pwdtxt1 = Iup::Create("text")
  79. Iup::SetAttribute(pwdtxt1, "PASSWORD", "YES")
  80. Iup::SetAttribute(pwdtxt1, "SIZE", "85x")
  81. pwdtxt2 = Iup::Create("text")
  82. Iup::SetAttribute(pwdtxt2, "SIZE", "85x")
  83. Iup::SetHandle ("pwdtxt1", pwdtxt1)
  84. Iup::SetHandle ("pwdtxt2", pwdtxt2)
  85. zbtxt = Iup::Zbox(pwdtxt1, pwdtxt2)
  86. Iup::SetHandle("zbtxt", zbtxt)
  87. Iup::Append(vb2, zbtxt)
  88. Iup::Append(hb3, vb2)
  89. Iup::Append(vb, hb3)
  90.  
  91. hb4 = Iup::Create("hbox")
  92. Iup::SetAttribute(hb4, "MARGIN", "35x")
  93. showpwd = Iup::Create("toggle")
  94. Iup::SetAttribute(showpwd, "TITLE", "Show Password?")
  95. Iup::SetAttribute(showpwd, "CANFOCUS", "NO")
  96. Iup::Append(hb4, showpwd)
  97. Iup::Append(vb, hb4)
  98.  
  99. hb5 = Iup::Create("hbox")
  100. Iup::SetAttribute(hb5, "MARGIN", "40x10")
  101. loginbut = Iup::Create("button")
  102. Iup::SetAttribute(loginbut, "TITLE", "Login")
  103. Iup::SetAttribute(loginbut, "EXPAND", "HORIZONTAL")
  104. iup::Append(hb5, loginbut)
  105. iup::Append(vb, hb5)
  106.  
  107. iup::Append(dlg, vb)
  108.  
  109. Iup::SetCallback(dlg,"CLOSE_CB",ADDRESS(Win_exit()))
  110. Iup::SetCallback(loginbut, "ACTION", ADDRESS(login_clicked()))
  111. Iup::SetCallback(showpwd, "ACTION", ADDRESS(show_password()))
  112.  
  113. Iup::Show(dlg)
  114. Iup::MainLoop()
  115. Iup::Close()
  116.  

90
Open Forum / Re: RaspberryBASIC.org Forum
« Last post by AIR on December 27, 2019, 08:09:22 PM »
Did this one on my Mac, using BlitzMax (there's no arm64 version available yet)

Code: Text
  1. Strict
  2.  
  3. Import MaxGUI.Drivers
  4.  
  5. Local window:    TGadget    =     CreateWindow("Logon",40,40,440,150,Null,WINDOW_TITLEBAR | WINDOW_CENTER)
  6. Local logo:        TGadget    =    CreatePanel(6,6,119,100, window)
  7. Local image:    TPixmap    =    LoadPixmap("login.png")
  8. Local lblUser:    TGadget    =     CreateLabel("Username:",110,16,90,22,window)
  9. Local txtUser:    TGadget    =    CreateTextField(190,16,240,22,window)
  10. Local lblPass:    TGadget    =     CreateLabel("Password:",110,48,90,22,window)
  11. Local txtPass:    TGadget    =    CreateTextField(190,48,240,22,window,TEXTFIELD_PASSWORD)
  12. Local btnLogin:    TGadget    =     CreateButton("Login",190,80,240,22,window)
  13. Local lblErr:    TGadget    =     CreateLabel("",126,100,260,60,window)
  14.  
  15. SetPanelPixmap logo,image
  16. SetGadgetFont(lblErr,LookupGuiFont(GUIFONT_SYSTEM,18,FONT_BOLD))
  17. SetGadgetColor(lblErr,255,0,0,False)
  18.  
  19. While True
  20.    WaitEvent
  21.    Select EventID()
  22.        Case EVENT_WINDOWCLOSE,EVENT_APPTERMINATE
  23.            End
  24.        Case EVENT_GADGETACTION
  25.            Select EventSource()
  26.             Case btnLogin
  27.                 Local user_password:String = GadgetText(txtPass)
  28.                 Local stupid_password:String = "pa$$w0rd!"
  29.                
  30.                 If user_password = stupid_password
  31.                     End
  32.                 Else
  33.                     SetGadgetText(lblErr,"** Invalid Password **")
  34.                 EndIf
  35.                
  36.             Case txtPass
  37.                 SetGadgetText(lblErr,"")                
  38.  
  39.            EndSelect
  40.    End Select
  41. Wend


If you enter the wrong password, when you go to re-enter it, the warning message goes away.... 8)

AIR.
Pages: 1 ... 7 8 [9] 10