PB2Web -- A PureBasic to JavaScript-Converter

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by Kwai chang caine »

Falsam wrote:The concept of window exists in android?
Hello FALSAM 8) :D
In fact for a time ANDROID do what you want, because the advantage to passing by HTML all that HTML can do...android forced to do in his explorer :mrgreen:
Thanks for your code, but KIFFI fix the bug 8)
Falsam wrote:(Sorry for my english kcc)
I'm happy you understand me....because when KCC speak english, every members of the forum nearly understand him except the english man :mrgreen: :lol:
Dialogs should be movable also on devices (thanks to Kcc)
Waaaaooouuhh !!!
Thank's that works now on ANDROID, they are not the pointer of mouse, but the windows move :shock:
KIFFI, you are the best KIFFI of all the KIFFI of the world !!!! 8)

It's me who thanks you, since all this years you help me 8)
Verry usefull idea !!!

May the force be with you !! 8)
Image
ImageThe happiness is a road...
Not a destination
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-15)

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

* Fixed several bugs in my parser (concerns comments and enumerations).

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 »

Thanks kiffi, testing it (modify my pb code, and trying to follow your recommendations) :

* Remove all API-Calls (including API-Constants)

* Adjust all variable-names because auf case-sensitivity

* Remove the event-loops and use the Binding-Commands instead

* Unsupported Commands (like Database-Commands, Preference-Commands and so on) must be placed in ProcedureDLL(), because the browser prohibits direct access to your filesystem. ProcedureDLL() are compiled to so-called 'CGI-BIN'. You have to install a webserver (IIS or Apache) for proper working.

Adding a new one : Don't name a variable or procedure by the name "new", reserved in javascript.

Is it possible for the next release to add the release number when executing Pb2web in the dos box ?
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
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:Is it possible for the next release to add the release number when executing Pb2web in the dos box ?
i have a version number (the current date):

Image

Greetings ... Kiffi
Hygge
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] »

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 »

Great one !
File -> Open file -> Nothing. Is this the normal bahviour ?
Purebasic 6.12 64 bits - Windows 11 Pro 64 bits 23H2
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] »

GG wrote:Great one !
File -> Open file -> Nothing. Is this the normal bahviour ?
Yes, I think the "file" and "requester" library aren't ok ;).
So My demo isn't finish at all.
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 »

[blendman] wrote:Yes, I think the "file" and "requester" library aren't ok ;).
at the moment, the 'UploadGadget' is not finished but i'm on it.

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 »

Hello Kiffi.
It is not possible to declare a global variable and a gadget with the same name.

Ex : user and #user

Code js

Code: Select all

var user;
var user = 1;
I do not know jquery. bug? not a bug?

Try this code : Enter data and Send

Code: Select all

XIncludeFile "D:\Applications\Pure Basic\Pb2Web\p2w.pbi"

P2W_Converter_SetProfile("pb2webtest")

Global user.s
Global location.s

Enumeration
  #mainform
  #user
  #location
  #button
EndEnumeration

P2W_Converter_Begin_Raw
  ;$('body').attr("id", "w_" + mainform);
P2W_Converter_End_Raw

Procedure DataRecord()  
  
  user = GetGadgetText(#user)
  location = GetGadgetText(#location)
  
  MessageRequester("Information", "User: "+ user + #CRLF$ + "Location: " + location) 
  
  ;Error debug : SetGadgetText: The specified Gadget is not initialized
  SetGadgetText(#user, "")
  SetGadgetText(#location, "")

  
EndProcedure

Procedure WindowShow()
  P2W_Converter_Begin_Comment
    OpenWindow(#mainform, 0,0, 800, 600,"")
  P2W_Converter_End_Comment  
  
  TextGadget(#PB_Any, 20, 40, 80, 25, "User")
  StringGadget(#user, 100, 40, 200, 22, "")
  
  TextGadget(#PB_Any, 20, 80, 80, 25, "Location")
  StringGadget(#location, 100, 80, 200, 22, "")
  
  ButtonGadget(#button, 310, 40, 80, 22, "Send")
  
  TextGadget(#PB_Any, 20, 350, 500, 22, "Proudly powered by Pure Basic & PB2Web") 
  
  BindGadgetEvent(#button, @DataRecord())
EndProcedure

WindowShow()

P2W_Converter_Begin_Comment
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
P2W_Converter_End_Comment
Rename #user by #myuser and #location by #mylocation.
Enter Data and send. No error.

➽ 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 »

unfortunately i have to remove the '#' - character during the conversion otherwise you get an javascript-error.

so '#user' becomes 'user' and stands in conflict with your regular 'user'-variable.

i think there is no other solution than to rename either your constant or your variable.

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 »

I renamed the constants. Thank you for the time you spend. :)

➽ 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 🤪
swan
Enthusiast
Enthusiast
Posts: 225
Joined: Sat Jul 03, 2004 9:04 am
Location: Sydney Australia
Contact:

Re: PB2Web -- A PureBasic to JavaScript-Converter

Post by swan »

Kowabunga Kiffi .... :D
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 »

I can send data to a php script.

■ My Pure Basic Code.

Code: Select all

XIncludeFile "D:\Applications\Pure Basic\Pb2Web\p2w.pbi"

P2W_Converter_SetProfile("pb2webtest")

Global Sortie.s, run, user.s, location.s

Enumeration
  #mainform
  #fmuser
  #fmlocation
  #button
EndEnumeration

P2W_Converter_Begin_Raw
  ;$('body').attr("id", "w_" + mainform);
P2W_Converter_End_Raw

Procedure DataRead()
  
EndProcedure

Procedure DataRecord()  
  Protected user.s
  Protected location.s
 
  user = GetGadgetText(#fmuser)
  location = GetGadgetText(#fmlocation)
  
  P2W_Converter_Begin_Raw
  ;$.ajax({
  ;   type: "GET",
  ;   url: 'test.php',
  ;   data: { action: "post", user: user, location: location }
  ;});
  P2W_Converter_End_Raw
  
  SetGadgetText(#fmuser, "")
  SetGadgetText(#fmlocation, "")  

  MessageRequester("Information", "Updated.")
EndProcedure

Procedure WindowShow()
  P2W_Converter_Begin_Comment
    OpenWindow(#mainform, 0,0, 800, 600,"")
  P2W_Converter_End_Comment  
    
  TextGadget(#PB_Any, 20, 20, 80, 25, "User")
  StringGadget(#fmuser, 100, 20, 200, 22, "")
  
  TextGadget(#PB_Any, 20, 50, 80, 25, "Location")
  StringGadget(#fmlocation, 100, 50, 200, 22, "")
  
  ButtonGadget(#button, 310, 20, 80, 22, "Click Here")
  
  TextGadget(#PB_Any, 20, 150, 500, 22, "Proudly powered by Pure Basic & PB2Web") 
  
  BindGadgetEvent(#button, @DataRecord())
EndProcedure

WindowShow()

P2W_Converter_Begin_Comment
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
P2W_Converter_End_Comment
■ My PHP Code (test.php).
For this test: Create a text file and add a user name and its location.

Code: Select all

<?php
if(isset($_GET['action']))
{
	$file = "users.txt";
	
	$crlf= "\r\n";
	
	if($_GET['action']=='post' AND isset($_GET['user']) AND isset($_GET['location']))
	{
	file_put_contents($file, $_GET['user']."|".$_GET['location'].$crlf, FILE_APPEND | LOCK_EX);
	}
}
echo "test";
?>
:?: I do not know how to use Ajax & pure basic to retrieve and read the data.
Last edited by falsam on Thu Jan 16, 2014 1:55 am, edited 2 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 »

try the ajax-success-function:

Code: Select all

Procedure DataRecord()  
  Protected user.s
  Protected location.s
 
  user = GetGadgetText(#fmuser)
  location = GetGadgetText(#fmlocation)
  
  Protected ReturnValue.s

  P2W_Converter_Begin_Raw
  ;$.ajax({
  ;   type: "GET",
  ;   url: 'test.php',
  ;   data: { action: "post", user: user, location: location },
  ;
  ;   success:function(data) {
  ;       ReturnValue = data; 
  ;    }
  ;
  ;});
  P2W_Converter_End_Raw
  
  MessageRequester("ReturnValue", ReturnValue)

  SetGadgetText(#fmuser, "")
  SetGadgetText(#fmlocation, "")  

  MessageRequester("Information", "Updated.")
EndProcedure
(untested)

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:try the ajax-success-function:
Error :
Uncaught TypeError: Cannot call method 'split' of undefined
http://localhost/p2web/librairies/pb2web/pb2web.js
1577

➽ 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 🤪
Locked