Is it possible to mimic ISQL Perform screen functionality (i.e. QBF, master/detail, etc.) with a 4GL program?
Like all the best answers, Yes, and No.
Yes: you can write a program that mimics the parts of the ISQL Perform interface that you want in I4GL. I've got at least two such programs of my own, and I know of two or three others produced by other people.
No: a single I4GL program cannot readily be made to handle all possible tables the way ISQL Perform does. The language is not powerful enough to permit that. So, the programs generated under the 'Yes' part of the answer are limited to the specific table that they were designed/written/generated to work against.
I4GL includes the CONSTRUCT statement which does almost everything that the ISQL Perform query option does. The only exceptions are the Perform '>>' and '<<' (maximum and minimum) operators; those require a major rewrite of the query rather than simply a different version of the WHERE clause.
You can code I4GL to handle Master/Detail. It is not incredibly hard, but neither is it trivial. My code generators never formalized that process, though.
Check out the Software Archive at the IIUG (International Informix Users Group) for the immediately available code generators. Contact me if you can't see either 'fglbld' or 'fglgen' there (see my profile).
Frank also asks:
So with I4GL I can have columns from different defined tables on the same screen and master/detail to each table?
Yes. Note that I4GL forms should only have one screen layout per form file (unlike ISQL Perform (sperform) which can have multiple screens in a single file). However, a single I4GL program can use as many forms as it needs to, so this isn't a serious handicap.
Or I can ad-hoc query to any column within the same table and enter my search criteria with the same relops used in Perform, except >> or <<?
Yes.
For a long time, I assumed that sformbld generated an I4GL object module which was executed by sperform (a forms engine). It sure would be nice to have a forms generator like perform built into I4GL for rapid prototyping, then be able to modify the 4GL code to further customize it.
ISQL pre-dates I4GL by a year or so - and is based on the pre-SQL Informix Perform program which is (was) still older. So, that is not how it is done.
One other question: Can Perform screens co-exist within I4GL?
It depends on exactly what you mean. There is a common subset of the Perform language that can be used by both ISQL and I4GL. However, there are many features (such as multiple screens, verify joins, and the instructions such as AFTER EDITADD) that can be used by ISQL but not I4GL, and others (notably screen records and screen arrays) that can be used by I4GL but not ISQL.
Related
I'm looking for some visual statechart-editor, for my customer. I'm building for him server application, and he needs tool to build statecarts and upload them to the servers. Ofcourse, the tool needs to have the capability to export to some readable format (such as SCXML), so I could build a reader for it.
I saw some tools, like fsm-editor. But they can't be good for me, because I want to limit my customer to set of specific set of parametrized-conditions, parametrized-events and parametrized-actions.
For example, I'll define:
conditions: coIsDoorOpen, coIsThereNAppelsOnTheTree(n as uint[0..200]), ...
events: evLightOn, evLightOff, evTimeout(ms as uint[1..10,000]), ...
actions: acSetAlarmOn, acCloseWindowN(n as uint[1..10]), ...
and my customer could build some dozens statecharts with those explicit predefined attributes (conds, events & actions), and upload the export of them to the approperiate places.
There is no need to be strict to one statechart-standard or to another. But I need support on this things:
parametrized conditions/events/actions
before entering/exiting state actions
no need to support inner variables; I can use actions&conditions for it.
Is there any tool for it (preferably free)?
If not - is there any OpenSource (C# / JS) implementation of editor that supports all abpve without the stricting of conds/events/actions, that I could easily break in to it and add the requested strict mode?
Based upon your needs, my knee-jerk reaction of recommending Visio or Dia would be inappropriate here. You appear to require a tool with some form of an API or descriptive language to lock users to a constrained set of components Lemmings-style, and your needs would best be serviced by something relatively simple if possible.
I'm curious why altering the source code to SCXML-GUI (fsm-editor) or Violet would not solve your needs, however. You seem to indicate that an open source utility written in C# or JavaScript is most desirable, which I cannot easily locate.
But, in the interests of completeness, here's a comparable question that may help your search. Most notably, this appears to be exactly what you desire and may be worth purchasing.
Best of luck with your project.
What is the difference between Stored Procedures and Prepared Statements... And which one is better and why...!! I was trying to google it but haven't got any better article...
Stored procedures are a sequence of instructions in PL/SQL language. Is a programming language implemented by some DBMS, that lets you store sequences of queries frequently applied to your model, and share the processing load with the application layer.
Prepared statements are queries written with placeholders instead of actual values. You write the query and it is compiled just once by the DBMS, and then you just pass values to place into the placeholders. The advantage of using prepared statements is that you enhance the performance considerably, and protect your applications from SQL Injection.
The difference is you cant store prepared statements. You must "prepare" them every time you need to execute one. Stored procedures, on the other hand, can be stored, associated to a schema, but you need to know PL/SQL to write them.
You must check if your DBMS supports them.
Both are very usefull tools, you might want to combine.
Hope this short explanation to be useful to you!
The other answers have hinted at this, but I'd like to list the Pros and Cons explicitly:
Stored Procedures
PROS:
Each query is processed more rapidly than a straight query, because the server pre-compiles them.
Each query need only be written once. It can be executed as many times as needed, even across different sessions and different connections.
Allows queries to include programming constructs (such as loops, conditional statements, and error handling) that are either impossible or difficult to write in SQL alone.
CONS
Require knowledge of whatever programming language the database server uses.
Can sometimes require special permissions to write them or call them.
Prepared Statements
PROS
Like stored routines, are quick because queries are pre-compiled.
CONS
Need to be re-compiled with each connection or session.
To be worth the overhead, each prepared statement must be executed more than once (such as in a loop). If a query is executed only once, more overhead goes into preparation of the prepared statement than you get back since the server needs to compile the SQL anyway, but also make the prepared statement.
For my money, I'd go with Stored Procedures every time since they only need to be written and compiled once. After that, every call to the procedure leads to saved time, whether you're on a new connection or not, and whether you're calling the procedure in a loop or not. The only downside is needing to spend some time learning the programming language. If I didn't have permissions to write stored procedures, I would use a prepared statement, but only if I had to repeatedly make the same query multiple times in the same session.
This is the conclusion I've come to after several months of off-and-on research into the differences between these two constructs. If anyone is able to correct bad generalizations I'm making, it will be worth any loss to reputation.
A stored Procedure is stored in the DB - depending on which DB (Oracle, MS SQL Server etc.) it is compiled and potentially prepared optimized when you create it on the server...
A prepared statement is a statement which is parsed by the server and an execution plan is created by the server ready for execution whenever you run the statement... usually it makes sense when a statement is run more than once... depending on the DB server (Oracle etc.) and even sometimes configuration options these "preparation" are either session-specific or "global"...
There is no "better" when you compare these two since they have their specific use cases...
I am working on a game in C++. I've been told, though, that I should also use an embeddable scripting language like Lua or Angelscript, but to be honest, I have no idea how or why. What advantages would this bring me, over storing all of my data in some sort of text file? How do I get started? I tried to read some Lua examples, but I don't see how it works, or how exactly I am supposed to use it.
First the "why" question:
If you've made reasonable progress so far, you have game scenery where the action happens, and then a kind of GUI with your visible game controls: Maps, compass, hotkeys, chat box, whatever.
If you make the GUI (positions, sizes, settings, defaults, etc) configurable through a configuration file, that's OK for starters. But if you make it controllable by code then you can do many very cool things. Example: Minimize the map when entering a city. Show other player's portraits when in group. Update the map. Display different hot keys in combat. That kinda thing.
Now you can do your code-controlling of your GUI in C/C++ code, but one problem is that whenever you want to change the behavior, even if only a little, you need to recompile the whole dang game client. If you have a billion players, you have to ship them all a new game client. That's a turn-off. Another problem is that there's no way on earth that a player can customize the GUI.
A simple embedded language solves both problem. You can put that kind of code in separate files that get loaded at runtime and can be fiddled with to anyone's heart's content. If you want to update the GUI in some minor way, you can deliver updates of the GUI code separately from the game proper.
As for the how:
The simplest thing to do is to call a (e.g.) Lua "main" routine once for every frame, perhaps passing a bunch of parameters with the latest updatable information, and let that main routine call other functions to do whatever's needed. The thing to be aware of is that your embedded code only gets control for a short time, namely the time between two screen refreshes; so it does a little updating and painting, then it exits again and returns control to your C/C++ main program loop.
Technically, embedding a Lua interpreter in your program is pretty easy. The Lua interpreter has C source code, or there's pre-compiled libraries (DLLs) for Windows. Just link them into your program, initialize once, call the entry point on every iteration of the main frame loop, done.
Scripts are more powerful than storing all of your data in text files. You can assign arbitrary behavior, construct data from other data (e.g., orc captains are orcs with a bit more), and so on.
Scripts allow for faster development and easier maintenance than C++. No compile / edit / link cycle, you can even tweak the scripts while the game is running, and they're easier to update on end users' machines.
As far as the how, one suggestion would be to see how other games do it. For example, TOME, a Roguelike RPG written in C, uses Lua extensively.
For some inspiration, check out the Alternate Hard and Soft Layers pattern described on the C2 wiki.
As for my two cents, why embed a scripting language? Some reasons that I've experienced include,
REPL
easy string manipulation tools
leverage the power of loops, macros, and recursion within your data set
create dynamically generated content
wrappers to fetch content from the web
logic to provide default values if data is missing
unit tests written at the data set level
I believe several of us have already worked on a project where not only the UI, but also data has to be supported in different languages. Such as - being able to provide and store a translation for what I'm writing here, for instance.
What's more, I also believe several of us have some time-triggered events (such as when expiring membership access) where user location should be taken into account to calculate, like, midnight according to the right time-zone.
Finally there's also the need to support Right to Left user interfaces accoring to certain languages and the use of diferent encodings when reading submitted data files (parsing text and excel data, for instance)
Currently I'm storing all my translations for all my entities on a single table (not so pratical as it is very hard to find yourself when doing sql queries to look into a problem), setting UI translations mainly on satellite assemblies and not supporting neither time zones nor right to left design.
What are your experiences when dealing with these challenges?
[Edit]
I assume most people think that this level of multiculture requirement is just like building a huge project. As a matter of fact if you tihnk about an online survey where:
Answers will collected only until
midnight
Questionnaire definition and part of
the answers come from a text file
(in any language) as well as
translations
Questions and response options must
be displayed in several languages,
according to who is accessing it
Reports also have to be shown and
generated in several different
languages
As one can see, we do not have to go too far in an application to have this kind of requirements.
[Edit2]
Just found out my question is a duplicate
i18n in your projects
The first answer (when ordering by vote) is so compreheensive I have to get at least a part of it implemented someday.
Be very very cautious. From what you say about the i18n features you're trying to implement, I wonder if you're over-reaching.
Notice that the big boy (e.g. eBay, amazon.com, yahoo, bbc) web applications actually deliver separate apps in each language they want to support. Each of these web applications do consume a common core set of services. Don't be surprised if the business needs of two different countries that even speak the same language (e.g. UK & US) are different enough that you do need a separate app for each.
On the other hand, you might need to become like the next amazon.com. It's difficult to deliver a successful web application in one language, much less many. You should not be afraid to favor one user population (say, your Asian-language speakers) over others if this makes sense for your web app's business needs.
Go slow.
Think everything through, then really think about what you're doing again. Bear in mind that the more you add (like Right to Left) the longer your QA cycle will be.
The primary piece to your puzzle will be extensive use of interfaces on the code side, and either one data source that gets passed through a translator to whichever languages need to be supported, or separate data sources for each language.
The time issues can be handled by the interfaces, because presumably you will want things to function in the same fashion, but differ in the implementation details. To a large extent, a similar thought process can be applied to the creation of the interface when adjusting it to support differing languages. When you get down to it, skinning is exactly this, where the content being skinned is the interface, and the look/feel is the implementation.
Do what your users need. For instance, most programmer understand English, there is no sense to translate posts on this site. If many of your users need a translation, add a new table column with the language id, and another column to link a translated row to its original. If your target auditory contains the users from the Middle East, implement Right to Left. If time precision is critical up to an hour, add a time zone column to the user table, and so on.
If you're on *NIX, use gettext. Most languages I've used have some level of support; PHP's is pretty good, for instance.
I'll describe what has been done in my project (it wasn't my original architecture but I liked it anyways)
Providing Translation Support
Text which needs to be translated have been divided into three different categories:
Error text: Like errors which happen deep in the application business layer
UI Text: Text which is shown in the User interface (labels, buttons, grid titles, menus)
User-defined Text: text which needs to be translatable according to the final user's preferences (that is - the user creates a question in a survey and he can also create a translated version of that survey)
For each different cathegory the schema used to provide translation service is different - so that we have:
Error Text: A library with static functions which access resource files
UI Text: A "Helper" class which, linked to the view engine, provides translations from remote assemblies
User-defined Text: A table in the database which provides translations (according to typeID of the translated entity and object id) and is linked to the entity via a 1 x N relationship
I haven't, however, attacked the other obvious problems such as dealing with time zones, different layouts and picture translation (if this is really necessary). Does anyone have tackled this problem in a different way?
Has anyone ever tackled the other i18n problems?
I learned some time ago about Decision Trees and Decision tables. I feel that Decision Tables can help with conditional If-Then-Else statements. In particular, I feel that Decision Tables have no side-effects, for example, if you didn't notice that you need one more "else if" statement.
But I am not sure how I can implement it. Arrays? Database Tables?
Does anyone even use Decision Tables in their code, nowadays?
I would highly recommend chapter 18 of Code Complete.
You could also check this post What Are Table Driven Methods
Well, I did my own research :S
This is something from IBM about decision tables used to make testing scenarios
This is from a company that makes decision tables that are then translated to if-then-else statements in vb.net.
Open source ruby workflow and bpm engine that uses decision tables.
So, I am still looking. If anyone has some good answers, please enter them in.
Multi-platform, CCIDE-0.5.0-6 (or later) is available at SourceForge and Github.
See the web page at http://twysf.users.sourceforge.net/
A table-driven method uses data structures instead of if-then statements to drive program logic. For example, if you are processing two types of records (tv versus cable) you might do this:
hash[tv] = processTvRecords
hash[cable] = processCableRecords
In some languages, like Ruby or Perl, this technique is straightforward. In Java, you'd need to use Reflection to find method handles.
If you want to learn about decision tables, investiagethe Fitnesse testing framework at http://fitnesse.org/.
By far the best implementation I've seen for decision tables is an application called Prologa, which is available for download at http://www.econ.kuleuven.be/prologa. Unfortunately, it's only available in Windows, and there can be a short delay while you wait for the evaluation key.
The software handles conditions that are non-binary, can collapse similar rules, and actually tracks the number of combinations that your table currently covers so it's great for completeness checks for particularly large tables. Also handles nested tables gracefully (where the result of one table can be the condition of another table).