|
Post by meerkat on Jun 28, 2020 11:02:36 GMT -5
I'm converting a program that uses HTML with a dynamic format. I never know the kind of data or the format is has until I execute the program and gather the info.
I'm trying to create a very simple test to dynamically create a textbox. For some reason I cannot get this eval command to work.
WindowWidth = 800 WindowHeight = 800 textbox #w.b,010,010,100,100 a = eval("textbox #w.a, 100,100,100,100") OPEN "test" for window_nf as #w #w "trapclose [mntExit]" wait [mntExit] close #w
What am I doing wrong? Maybe I'm doing this completely wrong and there is a simpler way.
Thanks for any help.
|
|
|
Post by Gordon Rahman on Jun 28, 2020 14:43:33 GMT -5
Hi Meerkat,
I'm not sure that I understand your question. But after the user resized a window you can open a new resized window with resized textboxes. Maybe you'll get ideas from the RESIZE section in the LB help file.
Gordon.
|
|
|
Post by meerkat on Jun 28, 2020 15:11:45 GMT -5
Maybe you'll get ideas from the RESIZE section in the LB help file.
Thanks Gordon..
That's not the problem. The problem is I don't know how many fields I'll need or what they should be. I may need anywhere from 1 to n fields. They could be a textbox, edit box, combo, or something else. So If I can "eval" the layout fields, I should be able to create any kind of layout I need. In the example, I just showed one textbox to see how to "eval" it. It won't accept it, so how do I dynamically lay out a screen?
Thanks for the help..
|
|
cundo
Full Member
Muchas Gracias!!
Posts: 146
|
Post by cundo on Jun 28, 2020 16:44:49 GMT -5
The thing is, you can't create controls using a loop, you must actually 'declare' them... unless you do some sort of API magic.
|
|
|
Post by meerkat on Jun 28, 2020 19:15:38 GMT -5
The thing is, you can't create controls using a loop
Actually I don't need to create controls like [Add], [Change], or [Delete].
I need to create the input form.
I'm trying to convert some Run Basic and RFO Basic programs. I have about 100+ tables in a database. Rather than write a maintenance program for each table, I have one Run/Rfo Basic program. It reads the DB table, and creates paged list (HTML <table>) with headings based on the Table definitions. There are [Add], [Change], and [Delete] buttons for each item in the list. It then produces the detail input form for the Add, Change, or Delete selection form the list. The program knows if it needs to do inner or outer joins, and if it needs combo boxes, edited, date, numeric, or text input, and it automatically has popup for date and time pickers. It does numeric and digital checks on the input.
If I can't do the same or something similar in LB, I'd have to write 100 programs.
So how do I write one maintenance program to handle most database tables..
Thanks for the help.. Dan
|
|
|
Post by Rod on Jun 29, 2020 1:45:09 GMT -5
You are going to have to “write a program on the fly” and then run that from your core program. It’s a bit like Freeform, you decide what components you need and script program code that creates what you want.
So you can’t open a window and amend its contents, you can’t use variables but you can write a script. Write a stand alone program that gives you what you want. Now think through how you would create that same script programmatically. So instead of variable named components you have literals, you would have #1, #1.textbox1 etc just as Freeform does.
Then you can run the script/program. It will open a new overlay window with the components you want. Crucially the script names components literally prior to the open command.
Alternatively you can have a pre opened window containing every kind of control you might use but held off screen or hidden. You could then move or show components you want to use and refresh.
In any event you will be running 100 different programs each fitting the database. Or you might just force the database to display into a fixed format single screen that holds every control you would need. So the screen never changes, you assign database fields to pre defined controls
|
|
|
Post by metro on Jun 29, 2020 2:22:07 GMT -5
G'Day Dan, Using LB4.5.1 and API's you could probably find a solution but it would be a logistical nightmare IMHO. Rod's idea is maybe the easiest, have a read of this www.libertybasicuniversity.com/lbnews/nl92/eightyseven.htmlyou could write your BAS to a file then create a TKN on the fly and "RUN", never tackled it so not sure of degree of difficulty or actual speed of execution. I'm guessing you are avoiding RunBasic because of the DB lockups, I wonder if Node.js could be used to access the SQlite Db and also for HTTPS. Just throwing it out there as that too could also be a nightmare.
It would be great if LB5 grid could store objects(checkbox,button or radiobutton)
Good Luck
|
|
|
Post by meerkat on Jun 29, 2020 7:35:51 GMT -5
Thanks you guys.
Correct Run Basic has db locks, and the -0.0d problem with numeric data, and a few other problems. I had some systems sitting and waiting for a fix, but it ain't happening so I thought I'm try LB. Then ran into this problem. I tried RFO and it has all the answers but one - it only runs on Android. Android is almost impossible to do client/server. And most of the other BASIC systems should not be called basic.
I spent days trying to solve this. I already tried the hidden fields and creating stuff on the fly. They were a mess. For the hidden stuff, I tried 100 layouts for each type of field such as editor, text, combo etc. Then tried to decide what ones I hide or show and then relocate them so it looks like a decent form. And how to get the popups like dates, checks for numeric and decimal, to tie to what fields. It was just too much of a mess. I tried the Grid. It worked ok because of the on the fly definitions, but you can only do one thing and that's test input.
I did write a program that automatically lays out a form based on your DB, or simply entering layout data. It works better than the current form layout. You can define a lineup column to line up everything, define tabs to line up if you want to go across. So if you want a multi column layout give it 2 columns or more. Left,right, top, and bottom margins are possible. You can tell it you have a grid and it insert Grids into the form. When you define a field you give it a caption that follows it as you insert stuff into the form. It's in debug shape, but I can finish it and make it available if you want. This worked the best, but then again you have 100 programs instead of a few.
I can go on with other things I tried. I learned some clever stuff along the way, but nothing was really workable.
Maybe someone knows how to get a Browser DLL to work. As you already know, all this works if you can do HTML. I'm not smart enough to know how to do this. The reason I tried RFO was because of the HTML interface. I submitted a LB5 "wish list" for HTML..
Thanks for the help.. Dan
|
|
|
Post by Rod on Jun 29, 2020 8:09:51 GMT -5
We have probably discussed ATL controls before. They can pop up a browser and run raw html code. But they cannot interact with the user. You need a server for that.
So this html code and this Liberty API code will pop up an input form that will take data. The submit button needs a php server. Is that the problem? You want Liberty to be the server?
<form action="/action_page.php"> <label for="fname">First name:</label><br> <input type="text" id="fname" name="fname" value="John"><br> <label for="lname">Last name:</label><br> <input type="text" id="lname" name="lname" value="Doe"><br><br> <input type="submit" value="Submit"> </form>
Save this away as test.html
nomainwin
WindowWidth=400 WindowHeight=300 UpperLeftX=1:UpperLeftY=1 menu #main, "&File","E&xit", [quit]
graphicbox #main.g, 0, 0, 100, 100
Open "Liberty Basic ATL Demo" For Window_nf As #main #main "TrapClose [quit]"
Open "atl" For DLL As #atl CallDLL #atl, "AtlAxWinInit", Ret As long
hWndViewer = hWnd(#main.g) 'Windows handle of graphicbox hMain = hWnd(#main) 'Windows handle of main window
STRUCT Rect,_ 'struct for storing client area rectangle leftX as long,_ 'upper left x upperY as long,_ 'upper left y rightX as long,_ 'lower right x lowerY as long 'lower right y
calldll #user32,"GetClientRect",_ hMain as ulong,_ 'window handle Rect as struct,_ 'name of struct r as long 'return cw = Rect.rightX.struct ch = Rect.lowerY.struct
'resize graphicbox to fill client area of window #main.g "locate 0 0 ";cw+2;" ";ch+2 #main "refresh"
CallDLL #user32, "GetWindowLongA", _ hWndViewer As ulong, _ 'handle of graphicbox _GWL_HINSTANCE As long, _ 'flag to get instance handle hInst As ulong 'returns instance handle of graphicbox
style = _WS_CHILD or _WS_VISIBLE or _WS_VSCROLL
open "test.html" for input as #html
html$ = "MSHTML:"+input$(#html,lof(#html)) close #html CallDLL #user32, "CreateWindowExA", _ _WS_EX_STATICEDGE As long, _ 'extended type "AtlAxWin" As ptr, _ 'class name html$ As ptr, _ 'URL, or progID or CLSID style As long, _ 'window style 0 As long, _ 'left x pos 0 As long, _ 'top y pos cw As long, _ 'width ch As long, _ 'height hWndViewer As ulong, _ 'handle of parent = graphicbox 100 As long, _ 'handle to menu or child window ID hInst As ulong, _ 'parent instance handle 0 As long, _ 'window creation data hATL As ulong 'handle of active template library control wait
[quit] Close #main close #atl 'close DLL after closing window end
|
|
|
Post by meerkat on Jun 29, 2020 16:22:46 GMT -5
I'm really not sure yet. Currently I'm running a server using Apache with LB and sending it HTML. I'll probably look into the Apache/LB approach. I'm sure that will work. I like the client/server to be interactive instead of batch. By that I mean that a lot of applications on the client side require users to fill out the entire form and then click the [Submit] button. If there's something like a customer number and item number and quantities and other stuff, you enter it all and then click [Submit]. Interactive forms would immediately submit the customer number after you enter it (onChange trigger). The server than looks up the customer and returns the customer info or an error into the web page.. So I have to make sure it can handle interactive screens. It should also work using localhost if you are running it on your computer.
Thanks for all the help.. Dan
|
|
|
Post by zzz000abc on Jul 10, 2020 1:46:24 GMT -5
|
|
|
Post by meerkat on Jul 10, 2020 6:40:40 GMT -5
Thanks zzz000abc, I did something similar to that a while back in a program called ionSQL. It looked at any table in your DB and creates a maintenance and stats for it. I think it's still available for download, but I'm not sure it still works.
|
|