Using Hidden Fields as Variables

Share sample pubs, scripts, etc. with other NeoBook users

Moderator: Neosoft Support

Locked
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

Using Hidden Fields as Variables

Post by fkapnist »

This is a demonstration PUB of how "hidden fields" can also be used as variables with persistence in NeoBook....

http://www.verticalbrowser.com/zips/hiddenfields.zip


Or just copy and paste the full code text into a new Pub file. No external files are required..


[syntax=neobook]
NBW Publication Source File
(C)2014 NeoSoft Corp.
Title=Untitled NeoBook Publication
Language=US
NeoBookVer=5.80
ScreenColors=16777216
ScreenWidth=800
ScreenHeight=600
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
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
Variables=[EnterText1]¶[moveEllipse]¶[Text1]¶[Text2]¶[TextEntry1]¶
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
EffectSpeed=0
PgEnterAction=SetVar "[CurrentDir]" "[TempDir]"¶FileWrite "[TempDir]getdata.cmd" "1" "echo %APPDATA%>apdat.txt"¶Run "[TempDir]getdata.cmd" "" "Hidden" "" ""¶FileToVar "apdat.txt" "[GetAppDataDir]"¶ExtractFilePath "[GetAppDataDir]*.*" "[AppDataPath]"¶FileRead "[AppDataPath]Text1.dat" "1" "[Text1]"¶.AlertBox "" "[Text1]"¶FileRead "[AppDataPath]Text2.dat" "1" "[Text2]"¶.AlertBox "" "[Text2]"¶FileRead "[AppDataPath]EnterText1.dat" "All" "[EnterText1]"¶.AlertBox "" "[EnterText1]"¶Setvar "[TextEntry1]" "[EnterText1]"¶FileRead "[AppDataPath]moveEllipse.dat" "1" "[moveEllipse]"¶.AlertBox "" "[moveEllipse]"¶If "[Text1]" "=" "red"¶SetObjectFill "Rectangle1" "Red" "Solid" "False"¶Else¶SetObjectFill "Rectangle1" "Blue" "Solid" "False"¶EndIf¶If "[Text2]" "=" "black"¶SetObjectFill "Rectangle2" "Black" "Solid" "False"¶Else¶SetObjectFill "Rectangle2" "White" "Solid" "False"¶EndIf¶If "[moveEllipse]" "=" "up"¶MoveObject "Ellipse1" "639" "1"¶EndIf¶If "[moveEllipse]" "=" "middle"¶MoveObject "Ellipse1" "639" "122"¶EndIf¶If "[moveEllipse]" "=" "down"¶MoveObject "Ellipse1" "648" "260"¶EndIf
PgExitAction=SetVar "[CurrentDir]" "[TempDir]"¶FileWrite "[TempDir]getdata.cmd" "1" "echo %APPDATA%>apdat.txt"¶Run "[TempDir]getdata.cmd" "" "Hidden" "" ""¶FileToVar "apdat.txt" "[GetAppDataDir]"¶ExtractFilePath "[GetAppDataDir]*.*" "[AppDataPath]"¶FileWrite "[AppDataPath]Text1.dat" "1" "[Text1]"¶FileWrite "[AppDataPath]Text2.dat" "1" "[Text2]"¶FileWrite "[AppDataPath]EnterText1.dat" "All" "[EnterText1]"¶FileWrite "[AppDataPath]moveEllipse.dat" "1" "[moveEllipse]"
ObjectType=7
Name=Line1
X1=15
Y1=333
X2=759
Y2=333
EndCaps=0
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16119285
FillPattern=0
TabOrder=2
ObjectType=5
Name=Rectangle1
X=28
Y=33
W=216
H=49
Anchor=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=255
FillPattern=0
TabOrder=3
ObjectType=5
Name=Rectangle2
X=28
Y=101
W=216
H=49
Anchor=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=0
FillPattern=0
TabOrder=4
ObjectType=3
Name=PushButton1
X=247
Y=32
W=88
H=19
Anchor=0
Text=red
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=SetObjectFill "Rectangle1" "Red" "Solid" "False"¶Setvar "[Text1]" "red"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=6
ObjectType=3
Name=PushButton2
X=249
Y=62
W=88
H=19
Anchor=0
Text=blue
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=SetObjectFill "Rectangle1" "Blue" "Solid" "False"¶Setvar "[Text1]" "blue"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=7
ObjectType=3
Name=PushButton3
X=248
Y=100
W=88
H=19
Anchor=0
Text=black
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=SetObjectFill "Rectangle2" "Black" "Solid" "False"¶Setvar "[Text2]" "black"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=8
ObjectType=3
Name=PushButton4
X=250
Y=130
W=88
H=19
Anchor=0
Text=white
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=SetObjectFill "Rectangle2" "White" "Solid" "False"¶Setvar "[Text2]" "white"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=9
ObjectType=9
Name=TextEntry1
X=27
Y=167
W=311
H=72
Anchor=0
Hint=Enter text here and click on save text...
VarName=[TextEntry1]
Align=1
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=10
ObjectType=3
Name=PushButton7
X=250
Y=248
W=88
H=19
Anchor=0
Text=save text
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=Setvar "[EnterText1]" "[TextEntry1]"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=5
ObjectType=6
Name=Ellipse1
X=639
Y=122
W=75
H=69
Anchor=0
LineColor=0
LineWidth=0
LineStyle=0
FillColor=32896
FillPattern=0
TabOrder=11
ObjectType=3
Name=PushButton8
X=524
Y=124
W=88
H=19
Anchor=0
Text=up
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=MoveObject "Ellipse1" "639" "1"¶Setvar "[moveEllipse]" "up"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=12
ObjectType=3
Name=PushButton9
X=524
Y=151
W=88
H=19
Anchor=0
Text=middle
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=MoveObject "Ellipse1" "639" "122"¶Setvar "[moveEllipse]" "middle"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=13
ObjectType=8
Name=Text1
X=31
Y=355
W=166
H=25
Anchor=0
Font=Arial
FontSize=8
FontStyle=1
FontCharset=1
TextColor=8404992
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs16\cf0\b [Text1]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=14
ObjectType=8
Name=Text2
X=31
Y=398
W=166
H=25
Anchor=0
Font=Arial
FontSize=8
FontStyle=1
FontCharset=1
TextColor=8404992
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs16\cf0\b [Text2]}}¶}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=15
ObjectType=8
Name=EnterText1
X=31
Y=436
W=166
H=48
Anchor=0
Font=Arial
FontSize=8
FontStyle=1
FontCharset=1
TextColor=8404992
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs16\cf0\b [EnterText1]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=16
ObjectType=8
Name=Text4
X=31
Y=493
W=166
H=25
Anchor=0
Font=Arial
FontSize=8
FontStyle=1
FontCharset=1
TextColor=8404992
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs16\cf0\b [moveEllipse]}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=17
ObjectType=3
Name=PushButton10
X=524
Y=175
W=88
H=19
Anchor=0
Text=down
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=MoveObject "Ellipse1" "648" "260"¶Setvar "[moveEllipse]" "down"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=18
ObjectType=3
Name=PushButton11
X=525
Y=380
W=147
H=27
Anchor=0
Text=Show Hidden
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=ShowObject "Text1" "None" "0"¶ShowObject "Text2" "None" "0"¶ShowObject "EnterText1" "None" "0"¶ShowObject "Text4" "None" "0"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=19
ObjectType=3
Name=PushButton12
X=525
Y=346
W=147
H=27
Anchor=0
Text=Hide Fields
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=HideObject "Text1" "None" "0"¶HideObject "Text2" "None" "0"¶HideObject "EnterText1" "None" "0"¶HideObject "Text4" "None" "0"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=20
ObjectType=8
Name=Text5
X=220
Y=456
W=518
H=85
Anchor=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs16\cf0 "Hidden Felds" can act as variables. In this example their values are automatically \plain\f0\fs16\cf0 stored (saved as small files to the Windows AppData folder) like cookies when the \plain\f0\fs16\cf0 program closes. Their values are automatically reloaded when the program starts up \plain\f0\fs16\cf0 again. Such fields should not be visible at initial state, or they should be put on a page \plain\f0\fs16\cf0 that users cannot see. When you close and restart the program, the field values will \plain\f0\fs16\cf0 remain persistent and can be used to trigger events, etc. }}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=21
ObjectType=3
Name=PushButton13
X=526
Y=413
W=147
H=27
Anchor=0
Text=Exit Demo
Align=2
ImageStyle=0
BevelWidth=1
XPTheme=Yes
ObjAction=FileErase "[AppDataPath]Text1.dat"¶Exit "" "Restart demo to see persistence."¶FileErase "[AppDataPath]Text2.dat"¶FileErase "[AppDataPath]EnterText1.dat"¶FileErase "[AppDataPath]moveEllipse.dat"¶SetVar "[persist]" "no"
LineColor=0
LineWidth=0
LineStyle=0
FillColor=128
FillPattern=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
TabOrder=22
ObjectType=8
Name=Text6
X=146
Y=294
W=470
H=33
Anchor=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=8404992
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs28\cf0\b Variables and Hidden Fields}}}
HMargin=0
VMargin=0
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=23
[/syntax]

It should be easy enough to understand....

8)
.
.
User avatar
fkapnist
Posts: 348
Joined: Mon Nov 17, 2014 4:24 pm
Location: Greece
Contact:

Re: Using Hidden Fields as Variables

Post by fkapnist »

You can do something similar without hidden fields using NeoBook's "SaveVariables" and "LoadVariables" actions.

:arrow:

.
Locked