Page 3 of 7

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 9:55 am
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

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 10:42 am
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

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 11:06 am
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 ?

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 11:16 am
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

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 3:08 pm
by [blendman]

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 4:00 pm
by GG
Great one !
File -> Open file -> Nothing. Is this the normal bahviour ?

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 4:08 pm
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.

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 4:20 pm
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

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 7:46 pm
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.

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 10:05 pm
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

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Wed Jan 15, 2014 10:56 pm
by falsam
I renamed the constants. Thank you for the time you spend. :)

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Thu Jan 16, 2014 12:18 am
by swan
Kowabunga Kiffi .... :D

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Thu Jan 16, 2014 12:50 am
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.

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Thu Jan 16, 2014 1:03 am
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

Re: PB2Web -- A PureBasic to JavaScript-Converter

Posted: Thu Jan 16, 2014 1:11 am
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