Page 1 of 1

IF command with Else and While

PostPosted: Sun Nov 05, 2017 8:21 am
by Dudus
Hi,

i have a few TextEntry, and i want to check IF TextEntry1 is empty than TextEntry1 change the color to red if is not empty than do nothing.
After that check TextEntry2 with the same features, than check TextEntry3... TextEntry 4.

If all of the TextEntries are filled THAN Alertbox say: OK!
How to do this?

Thank you!
Dudus

Re: IF command with Else and While

PostPosted: Sun Nov 05, 2017 9:25 am
by virger
Dos partes:
1) Las entradas
1) The TextEntryes

Code: Select all
{NeoBook 5 Objects}
NeoBookVer=5,80
ObjectType=9
Name=TextEntry1
X=69
Y=21
W=110
H=36
Anchor=0
VarName=[TextEntry1]
Align=1
EditLen=0
ObjAction=gosub "Accion"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=255
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=5
ObjectType=9
Name=TextEntry2
X=205
Y=21
W=110
H=36
Anchor=0
VarName=[TextEntry2]
Align=1
EditLen=0
ObjAction=gosub "Accion"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=255
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=4
ObjectType=9
Name=TextEntry3
X=341
Y=21
W=110
H=36
Anchor=0
VarName=[TextEntry3]
Align=1
EditLen=0
ObjAction=gosub "Accion"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=255
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=9
Name=TextEntry4
X=477
Y=21
W=110
H=36
Anchor=0
VarName=[TextEntry4]
Align=1
EditLen=0
ObjAction=gosub "Accion"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=255
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2


2) Y la sub-Rutina
2) And the sub-routine

Code: Select all
:Accion
if "[[Self]]" "=" ""
   SetObjectFill "[Self]" "Red" "Solid" "False"
endif
loop "1" "4" "[c]"
    if "[TextEntry[c]]" "<>" ""
        SetObjectFill "TextEntry[c]" "Lime" "Solid" "False"
    endif
endloop
Return


Me cuentas el resultado
You tell me the result

Re: IF command with Else and While

PostPosted: Sun Nov 05, 2017 11:30 am
by Dudus
Ok but where to put your {NeoBook 5 Objects} code?

Re: IF command with Else and While

PostPosted: Sun Nov 05, 2017 12:05 pm
by virger
Simple:
En una nueva area de trabajo de NB, haciendo copia del codigo (ctrl-c) y pegandolo (ctrl-v) y despues pulsando en esa nueva aplicacion F12 (se abre area de sub-rutinas) y haciendo lo mismo copias y pegas la sub-rutina llamada "accion" y listo, pulsas F9 para probarlo. Posteriormente si crees que te sirve le haces los ajustes necesarios.
Practicalo
+++++++++++++++++
Simple:
In a new work area of ​​NB, making a copy of the code (ctrl-c) and pasting it (ctrl-v) and then pressing in that new application F12 (it opens sub-routines area) and doing the same copies and you paste the Sub-routine called "accion" and ready, press F9 to test it. Later if you think it helps you, you make the necessary adjustments.
Practice it

Re: IF command with Else and While

PostPosted: Sun Nov 05, 2017 2:06 pm
by Dudus
Great it is works now :)

but I need a code like a "* Required fields are mandatory" and a button.

I tried this one:
IfEx "[TextEntry1]>[#32] and [TextEntry2]>[#32]"
AlertBox "ok" "All of the textfields are filled!"
Else
AlertBox "error" "* fields are Mandatory!"
Endif

But how to colorise a TextEntry which is empty?

Thank you!
Dudus

Re: IF command with Else and While

PostPosted: Mon Nov 06, 2017 8:19 am
by virger
Bueno Dudus, espero esto te sirva, por ahora mi ultima ayuda en este tema, esta es una aplicacion completa que le llamas como quieras, revisa las sub-rutinas. Gracias por leerme
++++++++++++++++
Well Dudus, I hope this serves you, for now my last help in this matter, this is a complete application that you call as you want, check the sub-routines. Thanks for reading me

Code: Select all
NBW Publication Source File
(C)2016 NeoSoft Corp.
Title=Untitled NeoBook Publication
Language=US
NeoBookVer=5,80
ScreenColors=16777216
ScreenWidth=540
ScreenHeight=250
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=28
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
SubroutineAction=:Change¶if "[[Self]]" "<>" ""¶   SetObjectFill "[Self]" "248,168,152" "Solid" "False"¶else¶   SetObjectFill "[Self]" "White" "Solid" "False"¶endif¶Return¶¶¶:Out¶if "[[Self]]" "<>" ""¶   SetObjectFill "[Self]" "248,168,152" "Solid" "False"¶else¶   SetObjectFill "[Self]" "White" "Solid" "False"¶endif¶Return¶¶¶:Accion¶if "[Current]" "<>" "[Self]"¶   setvar "[Current]" "[Self]"¶¶   if "[[Self]]" "=" ""¶      SetObjectFill "[Self]" "White" "Solid" "False"¶      setvar "[Current]" ""¶   else¶      SetObjectFill "[Self]" "248,80,48" "Solid" "False"¶   ¶   .#######¶      setvar "[count]" "0"¶      loop "5" "8" "[c]"¶           if "[TextEntry[c]]" "<>" ""¶              math "[Count]+1" "" "[Count]"¶           endif¶      endloop¶      ifex "[Count]>2 AND [Count]<4"¶         ...disableobject "BtExe"¶         AlertBox "ERROR" "* Fields Are Mandatory!"¶      else¶         if "[Count]" "=" "4"¶            ...enableobject "BtExe"¶            AlertBox "READY" "All Of The TextFields Are Filled!"¶         endif¶      endif¶   .#######¶   endif¶¶endif¶Return
ShapeTransColor=536870912
SplashProps=3
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
ReqExLevel=1
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
ObjectType=3
Name=BtExecute
X=363
Y=63
W=95
H=40
Anchor=0
Text=Execute¶(Enter)
Align=2
Key=13
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[count]" "0"¶loop "1" "4" "[c]"¶   if "[TextEntry[c]]" "<>" ""¶      math "[Count]+1" "" "[Count]"¶   endif¶endloop¶if "[Count]" "<" "4"¶   AlertBox "ERROR" "* Fields Are Mandatory!"¶else¶   AlertBox "READY" "All Of The TextFields Are Filled!"¶endif
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12566463
FillPattern=0
Font=Arial
FontSize=10
FontStyle=3
FontCharset=1
TextColor=0
TabOrder=5
ObjectType=9
Name=TextEntry1
X=13
Y=30
W=110
H=30
Anchor=0
VarName=[TextEntry1]
Align=1
EditLen=0
ObjAction=gosub "Change"
ObjSetFocusAction=SetObjectFill "[Self]" "144,184,248" "Solid" "False"
ObjLoseFocusAction=gosub "Out"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=0
ObjectType=9
Name=TextEntry2
X=149
Y=30
W=110
H=30
Anchor=0
VarName=[TextEntry2]
Align=1
EditLen=0
ObjAction=gosub "Change"
ObjSetFocusAction=SetObjectFill "[Self]" "144,184,248" "Solid" "False"
ObjLoseFocusAction=gosub "Out"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=1
ObjectType=9
Name=TextEntry3
X=285
Y=30
W=110
H=30
Anchor=0
VarName=[TextEntry3]
Align=1
EditLen=0
ObjAction=gosub "Change"
ObjSetFocusAction=SetObjectFill "[Self]" "144,184,248" "Solid" "False"
ObjLoseFocusAction=gosub "Out"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=9
Name=TextEntry4
X=421
Y=30
W=110
H=30
Anchor=0
VarName=[TextEntry4]
Align=1
EditLen=0
ObjAction=gosub "Change"
ObjSetFocusAction=SetObjectFill "[Self]" "144,184,248" "Solid" "False"
ObjLoseFocusAction=gosub "Out"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=3
ObjectType=9
Name=TextEntry5
X=13
Y=157
W=110
H=30
Anchor=0
VarName=[TextEntry5]
Align=1
EditLen=0
ObjAction=gosub "Accion"
ObjSetFocusAction=SetObjectFill "[Self]" "144,184,248" "Solid" "False"
ObjLoseFocusAction=gosub "Out"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=6
ObjectType=9
Name=TextEntry6
X=149
Y=157
W=110
H=30
Anchor=0
VarName=[TextEntry6]
Align=1
EditLen=0
ObjAction=gosub "Accion"
ObjSetFocusAction=SetObjectFill "[Self]" "144,184,248" "Solid" "False"
ObjLoseFocusAction=gosub "Out"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=7
ObjectType=9
Name=TextEntry7
X=285
Y=157
W=110
H=30
Anchor=0
VarName=[TextEntry7]
Align=1
EditLen=0
ObjAction=gosub "Accion"
ObjSetFocusAction=SetObjectFill "[Self]" "144,184,248" "Solid" "False"
ObjLoseFocusAction=gosub "Out"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=8
ObjectType=9
Name=TextEntry8
X=421
Y=157
W=110
H=30
Anchor=0
VarName=[TextEntry8]
Align=1
EditLen=0
ObjAction=gosub "Accion"
ObjSetFocusAction=SetObjectFill "[Self]" "144,184,248" "Solid" "False"
ObjLoseFocusAction=gosub "Out"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=9
ObjectType=7
Name=Line1
X1=0
Y1=109
X2=540
Y2=110
EndCaps=0
LineColor=0
LineWidth=2
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=12
ObjectType=8
Name=Inf2
X=14
Y=132
W=97
H=21
Anchor=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;\red0\green0\blue0;}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\margh720\margf720{\*\pnseclvl1\pnucrm\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl2\pnucltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl3\pndec\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl4\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{)}}}¶{\*\pnseclvl5\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl6\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl7\pnlcrm\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl8\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl9\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶\endnhere\sectdefaultcl{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs24\cf0 Option #2}}¶}
HMargin=0
VMargin=0
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=1
TabOrder=14
ObjectType=8
Name=Inf1
X=14
Y=5
W=97
H=21
Anchor=0
Font=Arial
FontSize=12
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\colortbl\red0\green0\blue0;\red255\green0\blue0;\red0\green128\blue0;\red0\green0\blue255;\red255\green255\blue0;\red255\green0\blue255;\red128\green0\blue128;\red128\green0\blue0;\red0\green255\blue0;\red0\green255\blue255;\red0\green128\blue128;\red0\green0\blue128;\red255\green255\blue255;\red192\green192\blue192;\red128\green128\blue128;\red0\green0\blue0;\red0\green0\blue0;}\paperw12240\paperh15840\margl1440\margr1440\margt1440\margb1440\margh720\margf720{\*\pnseclvl1\pnucrm\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl2\pnucltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl3\pndec\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{.}}}¶{\*\pnseclvl4\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb}{\pntxta{)}}}¶{\*\pnseclvl5\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl6\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl7\pnlcrm\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl8\pnlcltr\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶{\*\pnseclvl9\pndec\pnstart1\pnhang\pnindent720{\pntxtb{(}}{\pntxta{)}}}¶\endnhere\sectdefaultcl{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs24\cf0 Option #1}}¶}
HMargin=0
VMargin=0
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=1
TabOrder=13
ObjectType=3
Name=BtExe
X=363
Y=196
W=95
H=40
Anchor=0
Text=Execute¶(Enter)
Align=2
Key=13
ImageStyle=0
XPTheme=Yes
ObjAction=setvar "[count]" "0"¶loop "5" "8" "[c]"¶   if "[TextEntry[c]]" "<>" ""¶      math "[Count]+1" "" "[Count]"¶   endif¶endloop¶if "[Count]" "<" "4"¶   AlertBox "ERROR" "* Fields Are Mandatory!"¶else¶   AlertBox "READY" "All Of The TextFields Are Filled!"¶endif
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12566463
FillPattern=0
Font=Arial
FontSize=10
FontStyle=3
FontCharset=1
TextColor=0
TabOrder=4

Re: IF command with Else and While

PostPosted: Mon Nov 06, 2017 9:02 am
by Gaev
Dudus:

But how to colorise a TextEntry which is empty?

It is customary (on web pages at least) to draw the attention of a user to erroneous text entry fields by setting the border to a (glowing) red colour; in NeoBook you can not do "glowing", but you can use ...
Code: Select all
SetObjectLine "object name" "color" "width" "style"

... to change the border colour.

Re: IF command with Else and While

PostPosted: Tue Nov 07, 2017 1:13 pm
by Dudus
Thank you :) Its now OKay!