PB2Web -- A PureBasic to JavaScript-Converter

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by Kiffi »

Whow! Thanks for the stunning feedback! :D

New version available (2014-01-13):

Add: GetGadgetItemText() / SetGadgetItemText() for ComboBoxGadget() and ListViewGadget()

Add: (optional) Callback for LoadImage:

Code: Select all

Procedure LoadImageCallback(Image)
 ; here we are able to draw the image on a CanvasGadget() (e.g.)
EndProcedure

; LoadImage can be slow. So we have to use a callback
; to know when the image is completely loaded

LoadImage(#myImage, "i0.png", 0, @LoadImageCallback())
(thanks to dösbaddel from the german forum)

Add: Dialogs should be movable also on devices (thanks to Kcc)

Download here: http://pb2web.de/download/
Kwaï chang caïne wrote:but on android she's fix
please try again with the new version.
falsam wrote:I think P2W_Converter_SetApplicationName (ApplicationName.s) does not exist
yes, this is a old directive. I removed it (now in the documentation too ;-) ).
You can set the application name in the profile manager:

Image

Greetings ... Kiffi
Hygge
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by rsts »

You keep this up and you'll be a "Hero" for a lot of PB'ers.

cheers (and thanks).
User avatar
GG
Enthusiast
Enthusiast
Posts: 266
Joined: Tue Jul 26, 2005 12:02 pm
Location: Lieusaint (77), France

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by GG »

+1 :D
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
User avatar
GG
Enthusiast
Enthusiast
Posts: 266
Joined: Tue Jul 26, 2005 12:02 pm
Location: Lieusaint (77), France

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by GG »

Trying to test my six thousand lines project with the last release of pb2web (same thing with the previous one).

Parsing and compilation complete (with PB 5.21 64 bits), but when calling my URL via my browser :

Image

which corresponds to the following lines to pb2web generated file application.js :

Image

Any idea ? Linked with unimplemeted commands ?
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by falsam »

[Bug solved]

Hello Kiffi :) The canvas gadget does not work correctly with this new version.

■ Trying to draw on the canvas with the older version
http://s242132022.onlinehome.fr/pb2web/canvasdemo2

■ And now with the newversion.
http://s242132022.onlinehome.fr/pb2web/bug/canvasdemo2 (link remove)

When you click and move the mouse, the canvas slide on the window.
Last edited by falsam on Tue Jan 14, 2014 11:41 am, edited 4 times in total.

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by Kiffi »

GG wrote:six thousand lines project
:shock: :)

But seriously: it is very unlikely that existent projects runs out-of-the-box without modifications.

In your case:
Kiffi wrote:Please note the following rules (for now):

* Do not use event-loops. Better use the new Bind*()-Commands
But nevertheless there is a bug in my parser. Can you send me your 'original' PureBasic-Code (only the lines seen in the screenshot)?

Greetings ... Kiffi
Hygge
User avatar
GG
Enthusiast
Enthusiast
Posts: 266
Joined: Tue Jul 26, 2005 12:02 pm
Location: Lieusaint (77), France

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by GG »

Yes, I'm really conscious that it won't work in one click, like plug and play... :D
But your project seduces me a lot because I was about to translate my pb code to a Web application, and pb2web would help me a lot in this work.
Here are the following lines (procedure in my source pb code), hope it helps :

Code: Select all

Procedure modif_client2(noelement)
	Protected BWidth.l, BHeight.l, Quit.l, OffsetY.l
	If IsGadget(#Master_Ferie)
		; On cache l'éventuel gadget d'affichage des jours fériés
		HideGadget(#Master_Ferie,1)
	EndIf
	If IsGadget(#Frame_Master_Ferie)
		HideGadget(#Frame_Master_Ferie,1)
	EndIf
	EnableWindow_(WindowID(0), #False) 
	BWidth = 700 
	BHeight = 700 
	#BButtonHeight = 20 
	If OpenWindow(1, 0, 0, BWidth,BHeight, "Modification d'un Client - GenCalend" , #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_WindowCentered) 
		OffsetY = BHeight - #BButtonHeight - 5 
		ButtonGadget(#OK_Client, 5, OffsetY, (BWidth - 15) / 2, #BButtonHeight, "OK", #PB_Button_Default) 
		ButtonGadget(#Annuler_Client, 5 + (BWidth - 10 + 5) / 2, OffsetY, (BWidth - 15) / 2, #BButtonHeight, "Annuler") 
		DisableGadget(#Ajout_Client,1); Désactivation des boutons Ajouter
		DisableGadget(#Modif_Client,1); modifier
		DisableGadget(#Suppr_Client,1); et supprimer lors de la modification d'un client
		FrameGadget(117,190,10,220,80,"Nom du client :")
		BalloonTip(117,"Nom du client :","Spécifier le nom du client",#TOOLTIP_INFO_ICON, FontID(0),$CCF9FF, #Black) ; FontID(0) -> rappelle la fonte Tahoma 8
		FrameGadget(118,190,100,220,120,"Système d'exploitation :")
		ListViewGadget(#Os_Client,200,120,200, 80)
		ResetList(Client())
		SelectElement(Client(),noelement)
		amodif=Client()\nocli
		StringGadget(#Nom_Client,200,40,200,20,Client()\libcli)    ; 
		ResetList(os());
		Position=0
		While NextElement(os())
			AddGadgetItem(#Os_Client,-1,os()\libos)   ; Choix des OS
			If os()\noos=Client()\noos
				pos_os=Position
			EndIf
			Position=Position+1
		Wend
		FrameGadget(119,190,230,220,130,"SGBD du client :")
		ListViewGadget(#Sgbd_Client,200,260,200, 80)
		ResetList(sgbd())
		Position=0
		While NextElement(sgbd())
			AddGadgetItem  (#Sgbd_Client,-1,sgbd()\libsgbd)   ; Choix des SGBD
			If sgbd()\nosgbd=Client()\nosgbd
				pos_sgbd=Position
			EndIf
			Position=Position+1
		Wend
		SetGadgetState(#Os_Client,pos_os); On affiche la valeur de l'OS par défaut
		SetGadgetState(#Sgbd_Client,pos_sgbd); On affiche la valeur du SGBD par défaut
		CheckBoxGadget(#Purge_Client,200,360,120,40,"Purge de Calend")
		GadgetToolTip(#Purge_Client,"Si coché, génére la commande permettant de supprimer les enregistrements de CALEND pour l'année et le marché concernés.")
		SetGadgetState(#Purge_Client,Client()\purge)
		EditorGadget(#Divers,200,550,350,100)
		AddGadgetItem(#Divers,-1,Client()\divers)
		CheckBoxGadget(#InstExec_Client,200,400,150,30,"Instruction d'exécution")
		GadgetToolTip(#InstExec_Client,"Insère un commit en fin de script")
		SetGadgetState(#InstExec_Client,Client()\instexec)
		FrameGadget(116,190,450,200,70,"Libellé court : ")
		FrameGadget(115,190,530,390,130,"Divers : ")
		GadgetToolTip(#Nom_Client,"Nom du Client")
		GadgetToolTip(#Os_Client,"Système d'exploitation du client")
		GadgetToolTip(#Sgbd_Client,"SGBD utilisé par le client")
		StringGadget(#MiniLib,200,480,180,20,Client()\minilib)
		GadgetToolTip(#MiniLib,"Nom court, pour le nom du fichier généré")
		DisableGadget(#OK_Client,0); On réactive le bouton OK, on testera ensuite si toutes les infos sont là
		Flag=0
		Quit=#False
		Repeat 
			EventID3=WaitWindowEvent();
			If EventID3= #PB_Event_CloseWindow 
				Quit = #True 
			EndIf
			If EventID3=#PB_Event_Gadget
				Select EventGadget();
					Case #OK_Client; Appui sur OK
						os=GetGadgetState(#Os_Client); On récupère l'OS
						sgbd=GetGadgetState(#Sgbd_Client); On récupère le SGBD
						If os=-1
							MessageRequester("Informations manquantes", "L'O.S. n'est pas renseigné",#PB_MessageRequester_Ok);
						Else
							If sgbd=-1
								MessageRequester("Informations manquantes", "Le SGBD n'est pas renseigné",#PB_MessageRequester_Ok);
							Else
								client$=GetGadgetText(#Nom_Client); On récupère le Nom du client 
								indice=1
								ResetList(Client())
								ResetList(os())
								SelectElement(os(),os)
								ResetList(sgbd())
								SelectElement(sgbd(),sgbd)
								trouve=0
								SelectElement(Client(),noelement)
								Client()\libcli=client$; Pour le client modifié,
								Client()\noos=os()\noos; on met à jour le contenu de la liste chainée
								Client()\nosgbd=sgbd()\nosgbd
								;Client()\entete=GetGadgetText(#Entete_Client)
								Client()\purge=GetGadgetState(#Purge_Client)
								Client()\instexec=GetGadgetState(#InstExec_Client)
								Client()\minilib=GetGadgetText(#MiniLib)
								Client()\divers=GetGadgetText(#Divers)
								Insert_Trace(#Event_Trace_Modif_Client,Client()\libcli+" / Nocli : "+Str(Client()\nocli))
								Update_Client()
								SetGadgetItemText(#Liste_Client,noelement,Str(Client()\nocli),0); Mise à jour de l'enregistrement visuellement
								SetGadgetItemText(#Liste_Client,noelement,client$,1); 
								SetGadgetItemText(#Liste_Client,noelement,os()\libos,2);
								SetGadgetItemText(#Liste_Client,noelement,sgbd()\libsgbd,3);
								SetGadgetItemText(#Liste_Client,noelement,Client()\entete,4);
								SetGadgetItemText(#Liste_Client,noelement,Chr(78+Client()\purge),5);
								SetGadgetItemText(#Liste_Client,noelement,Chr(78+Client()\instexec),6);
								SetGadgetItemText(#Liste_Client,noelement,Client()\minilib,7)
								SetGadgetItemText(#Liste_Client,noelement,Client()\divers,8)
								Quit=#True
							EndIf
						EndIf
					Case #Annuler_Client; Appui sur Annuler
						Quit=#True
				EndSelect 
			EndIf
		Until Quit=#True
		DisableGadget(#Ajout_Client,0); Activation de Ajouter
		DisableGadget(#Modif_Client,1); désactivation de modifier
		DisableGadget(#Suppr_Client,1); et supprimer 
		DisableGadget(#Generer,0); On active la génération de calendriers
		UseGadgetList(WindowID(0)) 
		CloseWindow(1) 
		EnableWindow_(WindowID(0), #True) 
		SetActiveWindow(0) 
	EndIf
EndProcedure
Possible to send you (in PM) the whole code if necessary.
Thanks a lot in advance.
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by falsam »

[Bug solved]
All gadgets slide out of the window when you click (without releasing) and moves the mouse.
Last edited by falsam on Tue Jan 14, 2014 11:39 am, edited 1 time in total.

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by Kiffi »

falsam wrote:All gadgets slide out of the window when you click (without releasing) and moves the mouse.
for a quick fix: open \system\libraries\pb2web\pb2web.js with
a texteditor, search for selector.draggable(); and delete this line.

I will upload a fixed version as soon as possible.

Greetings ... Kiffi
Hygge
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by falsam »

Kiffi wrote:for a quick fix: open \system\libraries\pb2web\pb2web.js with
a texteditor, search for selector.draggable(); and delete this line.
Thank Kifi. Bug Done :)

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
swhite
Enthusiast
Enthusiast
Posts: 783
Joined: Thu May 21, 2009 6:56 pm

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by swhite »

This does look interesting. Currently I use the SparkGateway from http://www.remotespark.com/html5.html to put my applications in the browser (it works on Windows and Linux servers). There are similar products such as Ericom's AccessNow and 2X HTML5 Client among others.

Simon
Simon White
dCipher Computing
User avatar
[blendman]
Enthusiast
Enthusiast
Posts: 297
Joined: Thu Apr 07, 2011 1:14 pm
Location: 3 arks
Contact:

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by [blendman] »

Hi

It's amazing ! One of the big evolution for Purebasic, thank you very much Kiffi !!

I have tried it and it's great.
Do you think to add the 2D library (screen, sprite) ?

Thank you a lot.
User avatar
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by Kiffi »

New version is online (2014-01-14)

Download here: http://pb2web.de/download/

* Fixed 'movable' Gadgets (thanks to falsam)

* Add: Set/GetGadgetItemText for Editor- and WebGadget()

* Fixed several bugs in my parser. (to be continued...)

Special thanks to GG with his six thousand lines touchstone :-)
[blendman] wrote:Do you think to add the 2D library (screen, sprite) ?
there is still so much to do and so little time. Image

The 2D-Library has no high priority because my 2D-knowledge is very poor, but i will see what I can do

Greetings ... Kiffi
Hygge
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by J. Baker »

[blendman] wrote:Do you think to add the 2D library (screen, sprite) ?
http://purebasic.fr/german/viewtopic.ph ... =pbtohtml5 ;)
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by flaith »

Just awesome :shock:
Nice work Kiffi :D
“Fear is a reaction. Courage is a decision.” - WC
Locked