vbScript Example: Write to text file, read first 7 characters in file and display result

This method reads the number of characters you specify from a Textstream file and returns them as a string. If you specify more characters than actual exist in the file, then Read only returns the actual number of characters that are in the file. The results are stored in the [result] neobook variable.

:Code

dim filesys, text, readfile, contents
set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\somefile2.txt")
text.Write "A quick example of the Read method"
text.close
set readfile = filesys.OpenTextFile("c:\somefile2.txt", 1, false)
contents = readfile.Read(7)
readfile.close

publication.nbSetVar "[result]", "The first seven characters in the text file are '" & contents & "'."

:End Code

You can use vbscript in NeoBook RAD5. Click here.

NeoBook 5.6.4 Update Released

NeoSoft Corp. has released NeoBook version 5.6.4.

NOTE: If you registered NeoBook 5 before February 1st 2008 then you will need to purchase a new registration code in order to use version 5.6 or higher. If you purchased NeoBook 5 after February 1st 2008, then this upgrade is free. Registered users of NeoBook 5.0 through 5.5.4 can purchase a new registration code for $25.

This update contains the following:

Enhancements

-Added an option to Book Properties > Version Info to allow customization of the Vista/Windows 7 manifest included in compiled publications. Most NeoBook authors can safely ignore this feature and simply use the default "As Invoker" setting. Versions of Windows prior to Vista will ignore the manifest. (See the “Book Properties > Global” topic in the help file for more information about this feature.)

-Compiled publications now attempt to detect changes to the default printer made by the Windows Control Panel or other applications. Previously, a change in the default printer would not be recognized until the publication was restarted. (Note to Programmers: Your app should broadcast a WM_SETTINGCHANGE message if you alter the default printer.)

Fixes

-The Archive/Backup command now works correctly. A bizarre glitch in the software we use to “protect” NeoBook from hackers unexpectedly caused this feature to stop working in v5.6.3. Only the English version was affected.

-Corrected two compatibility issues related to Internet Explorer 8. The first caused an error message to appear when closing compiled publications containing embedded HTML content. The second prevented NeoBook from test running ActiveX (PKG) publications (formally known as web browser plug-ins) when IE8 was installed.

-Corrected a problem that prevented NeoBook from running on some Windows 95/98 systems. This was caused by a compatibility issue with the software used to “protect” NeoBook from hackers. This affected NeoBook only and not compiled publications.

-Corrected a problem that prevented Web Browser objects from redrawing properly when snapped to a container.

-The help file’s search feature now works correctly after being inadvertently disabled in the previous update.

Other

-The compiler option “Web Browser Plug-In“ was changed to “ActiveX Control (PKG)” which more accurately reflects the type of application created. Hopefully, this will reduce confusion (and tech support questions) about this feature.

Download here:

http://clickcoders.org/cgi-bin/download.pl?file=nbw.exe

NeoBook Function: Convert Long Day and Month to Short

There are times when you may need to convert long days (Sunday) into short days (Sun), and long months into short months. An easy way to do this is to put the conversion code into a NeoBook function, and then call it whenever you need it.

For example, an RSS xml feed requires the published date in this format: Fri, 14 Nov 2008 09:11:18. To code a button that will do this when clicked, create 2 new functions (Options|Function Library), name them Convert Long Day to Short and Convert Long Month to Short (or anything you like), and paste the following code into them:

DAY FUNCTION

If "[day]" "=" "Monday"
SetVar "[shortday]" "Mon"
endif

If "[day]" "=" "Tuesday"
SetVar "[shortday]" "Tue"
endif

If "[day]" "=" "Wednesday"
SetVar "[shortday]" "Wed"
endif

If "[day]" "=" "Thursday"
SetVar "[shortday]" "Thu"
endif

If "[day]" "=" "Friday"
SetVar "[shortday]" "Fri"
endif

If "[day]" "=" "Saturday"
SetVar "[shortday]" "Sat"
endif

If "[day]" "=" "Sunday"
SetVar "[shortday]" "Sun"
endif

MONTH FUNCTION

If "[month]" "=" "January"
SetVar "[shortmonth]" "Jan"
endif

If "[month]" "=" "February"
SetVar "[shortmonth]" "Feb"
endif

If "[month]" "=" "March"
SetVar "[shortmonth]" "Mar"
endif

If "[month]" "=" "April"
SetVar "[shortmonth]" "Apr"
endif

If "[month]" "=" "May"
SetVar "[shortmonth]" "May"
endif

If "[month]" "=" "June"
SetVar "[shortmonth]" "Jun"
endif

If "[month]" "=" "July"
SetVar "[shortmonth]" "Jul"
endif

If "[month]" "=" "August"
SetVar "[shortmonth]" "Aug"
endif

If "[month]" "=" "September"
SetVar "[shortmonth]" "Sep"
endif

If "[month]" "=" "October"
SetVar "[shortmonth]" "Oct"
endif

If "[month]" "=" "November"
SetVar "[shortmonth]" "Nov"
endif

If "[month]" "=" "December"
SetVar "[shortmonth]" "Dec"
endif

In your button, enter this code:

... Convert day and month
Call "Convert to short day"
Call "Convert to short month"
... Copy to clipboard
SetVar "[clipboard]" "[shortday], [daynum] [shortmonth] [year] [hour]:[minute]:[second]"
... Paste from clipboard
SendKeys "" "{CtrlDn}v{CtrlUp}"

These two could be combined into one function, but since you may not need both for your application, we're using 2 functions. If you don't need the time, year etc., just delete those variables from the setvar action.

To use them, locate your cursor in a textentry object where you want the date and time to appear, click the button, and voila!, there it is.

:: Next >>