Page 4 of 7
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 1:26 am
by Kiffi
sorry, my fault
this one is correct (you have to use callbacks):
Code: Select all
Procedure GetData_Success(ReceivedData.s)
MessageRequester("Success", ReceivedData)
SetGadgetText(#fmuser, "")
SetGadgetText(#fmlocation, "")
EndProcedure
Procedure GetData_Error(a.s, b.s, c.s)
MessageRequester("Error", b + " / " + c)
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 },
;
; success : function(data) {
; GetData_Success(data);
; },
;
; error : function(a, b, c) {
; GetData_Error(a, b, c);
; }
;
;});
P2W_Converter_End_Raw
EndProcedure
Greetings ... Kiffi
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 1:41 am
by falsam
Excellent Kiffi!! I did not realize it was possible to call a procedure PureBasic from ajax code. That's great

Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 4:18 am
by Poshu
I was wondering : can we take part in the development of PB2Web?
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 12:36 pm
by Kiffi
@falsam:
same solution with ServerCode (CGI). No need to code in ugly PHP
Code: Select all
ProcedureDLL.s WriteUserAndLocation(User.s, Location.s)
Protected FF
FF = OpenFile(#PB_Any, "test.txt", #PB_File_Append)
If FF
WriteStringN(FF, User + "|" + Location)
CloseFile(FF)
ProcedureReturn "OK"
Else
ProcedureReturn "!OpenFile()"
EndIf
EndProcedure
Procedure DataRecord()
Protected user.s
Protected location.s
Protected ReturnValue.s
user = GetGadgetText(#fmuser)
location = GetGadgetText(#fmlocation)
ReturnValue = WriteUserAndLocation(user, location)
If Left(ReturnValue, 2) = "OK" ; ReturnValue contains linebreak
SetGadgetText(#fmuser, "")
SetGadgetText(#fmlocation, "")
MessageRequester("Information", "Updated.")
Else
MessageRequester("Information", "Something went wrong")
EndIf
EndProcedure
@Poshu: Thanks for the offer! I will think about it.
Greetings ... Kiffi
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 1:02 pm
by [blendman]
Hi
1) Some informations on PB2Web (for Kiffi

) :
In a procedure, this code doesn't work (same with - * / ):
We have to use :
This code doesn't work (in a procedure) :
Code: Select all
Select x
Case 0
Select y
Case 0
; ...
Case 1
; ...
EndSelect
Case 1
Select y
Case 0
; ...
Case 1
; ...
EndSelect
EndSelect
We have to use :
Code: Select all
If x = 0
Select y
Case 0
; ...
Case 1
; ...
EndSelect
ElseIf x = 1
Select y
Case 0
; ...
Case 1
; ...
EndSelect
Endif
Not implemented for the moment ?
- EventMenu() : It send "undefined" as returned value

(It's not finished, I suppose

).
- ButtonImageGadget() : we can create the button, but for the moment, the bind event isn't implemented, it's exact ?
- Drawtext() : not implemented ? We have a debug message : "alpha isn't implemented" (I like Alpha : RGBA(), DrawAlphaImage()...

)
2) A new version of my Paint test program :
http://www.dracaena-studio.com/purebasic/paint/
New :
- we can use image to draw (some brush are from the SlotMachine demo, thanks

)
- Tool : eraser, clear, brush
- panel Layers/options (Only UI)
Source (zip):
http://www.dracaena-studio.com/purebasi ... int0.1.zip
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 1:59 pm
by Kiffi
[blendman] wrote:In a procedure, this code doesn't work (same with - * / ):
annotation:
x + 1 works but
x\something + 1 doesn't work.

I'am on it.
[blendman] wrote:Select [...]
mmmh. This one works:
Code: Select all
Define x = 1
Define y = 0
Select x
Case 0
Select y
Case 0
Debug "x=0 y=0"
Case 1
Debug "x=0 y=1"
EndSelect
Case 1
Select y
Case 0
Debug "x=1 y=0"
Case 1
Debug "x=1 y=1"
EndSelect
EndSelect
can you provide a simple snippet to reproduce the error?
[blendman] wrote:
- EventMenu() : It send "undefined" as returned value

(It's not finished, I suppose

).
- ButtonImageGadget() : we can create the button, but for the moment, the bind event isn't implemented, it's exact ?
implementet, but not published. Stay tuned.
[blendman] wrote:
- Drawtext() : not implemented ? We have a debug message : "alpha isn't implemented" (I like Alpha : RGBA(), DrawAlphaImage()...

)
yes, unfortunately the most of the 2DDrawing-Library functions aren't implemented.
Greetings ... Kiffi
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 2:34 pm
by falsam
Kiffi wrote:can you provide a simple snippet to reproduce the error?
Code: Select all
XIncludeFile "D:\Applications\Pure Basic\Pb2Web\p2w.pbi"
P2W_Converter_SetProfile("pb2webtest")
Procedure dummy(x)
Select x
Case 1,3
Debug "Value is 1 or 3"
Case 10 To 20
Debug "this value is between 10 and 20"
Default
Debug "Hmmm ...I don't know"
EndSelect
EndProcedure
dummy(10)
A problem with "To"
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 3:33 pm
by [blendman]
Kiffi wrote:annotation:
x + 1 works but
x\something + 1 doesn't work.

I'am on it.
ok, great !
[blendman] wrote:Select [...]
mmmh. This one works
Yes, it work. Sorry, I have the version 2014/01/14 and not the 2014/01/15 of PB2Web

.
[blendman] wrote:
- EventMenu() : It send "undefined" as returned value

(It's not finished, I suppose

).
- ButtonImageGadget() : we can create the button, but for the moment, the bind event isn't implemented, it's exact ?
implemented, but not published. Stay tuned.
It's a great news ! I'm waiting (PB2Web is magic

).
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 3:57 pm
by falsam
Kiffi wrote:No need to code in ugly PHP

Yes my code PHP is ugly
Thanks for your reply but i can't register data.
■ My code (
with your help)
Code: Select all
XIncludeFile "D:\Applications\Pure Basic\Pb2Web\p2w.pbi"
P2W_Converter_SetProfile("pb2webtest")
Enumeration
#mainform
#fmuserslist
#fmuser
#fmlocation
#fmuserupdate
EndEnumeration
ProcedureDLL.s WriteUserAndLocation(User.s, Location.s)
Protected FF
FF = OpenFile(#PB_Any, "users.txt", #PB_File_Append)
If FF
WriteStringN(FF, User + "|" + Location)
CloseFile(FF)
ProcedureReturn "OK"
Else
ProcedureReturn "!OpenFile()"
EndIf
EndProcedure
Procedure DataRecord()
Protected user.s
Protected location.s
Protected ReturnValue.s
user = GetGadgetText(#fmuser)
location = GetGadgetText(#fmlocation)
If Trim(user) = ""
MessageRequester("Information", "The username you entered is too short.")
Else
ReturnValue = WriteUserAndLocation(user, location)
Debug "WriteUserAndLocation say " +ReturnValue
If Left(ReturnValue, 2) = "OK" ; ReturnValue contains linebreak
SetGadgetText(#fmuser, "")
SetGadgetText(#fmlocation, "")
MessageRequester("Information", "Updated.")
AddGadgetItem(#fmuserslist, -1, user+Chr(10)+location)
Else
MessageRequester("Information", "Something went wrong")
EndIf
EndIf
EndProcedure
Procedure WindowShow()
OpenWindow(#mainform, 0, 0, 450, 450, "Demo : Test open and write file", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
SetWindowColor(#mainform, RGB(255, 239, 213))
ListIconGadget(#fmuserslist, 20, 40, 400, 300, "User", 200)
AddGadgetColumn(#fmuserslist, 1, "Location", 200)
TextGadget(#PB_Any, 20, 350, 80, 25, "User")
StringGadget(#fmuser, 100, 350, 200, 22, "")
TextGadget(#PB_Any, 20, 390, 80, 25, "Location")
StringGadget(#fmlocation, 100, 390, 200, 22, "")
ButtonGadget(#fmuserupdate, 310, 350, 80, 22, "Update")
TextGadget(#PB_Any, 20, 430, 400, 22, "Proudly Powered by <b>Pure Basic</b> & <b>PB2Web</b>")
BindGadgetEvent(#fmuserupdate, @DataRecord())
EndProcedure
WindowShow()
P2W_Converter_Begin_Comment
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
P2W_Converter_End_Comment
■ Profile Manager setting.
■ Result when I am trying to validate a user.
■ Test Zone (
Profile Manager is update)
Server 1and1 (linux)
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 8:35 pm
by Kiffi
@falsam: Thanks for the snippet. I will check it.
falsam wrote:Server 1and1 (linux)
ok, that's the reason. PB2Web compiles the ServerCode to an
Windows-Executable, so you cannot use it on a Linux-Server.
Therefore unfortunately you must to continue to code in PHP.
Greetings ... Kiffi
// Edit: oh, sorry, i see that you are using WAMPP. So your Apache
is configured, that he sends you the EXE instead of executing it.
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 8:47 pm
by venom27
Bravo, excellent work.
Good luck...
@++
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 9:03 pm
by Tenaja
Kiffi wrote:PB2Web compiles the ServerCode to an Windows-Executable, so you cannot use it on a Linux-Server.
Others have done essentially the same thing, and posted it here on the forum, sharing source that works with both Windows and Linux servers.
http://purebasic.fr/english/viewtopic.p ... 1&p=379023
http://www.purebasic.fr/english/viewtopic.php?p=133389
http://www.purebasic.fr/english/viewtop ... 14&t=37397
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 9:36 pm
by falsam
Kiffi wrote:Therefore unfortunately you must to continue to code in PHP.
code in ugly PHP

Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 9:48 pm
by Kiffi
Tenaja wrote:Others have done essentially the same thing
PB2Web compiles this [1] code from Deluxe0321 (modified a little bit by me)
on the fly (during parsing the code). The source can be found under
'[...]\pb2web\system\CGI\' but nevertheless the executable-format
depends on the underlying OS.
[1]:
http://www.purebasic.fr/english/viewtop ... 12&t=35321
Greetings ... Kiffi
Re: PB2Web -- A PureBasic to JavaScript-Converter
Posted: Thu Jan 16, 2014 11:38 pm
by falsam
Angry with the cgi, I changed my test code. I communicate with a php script that allows you to add and list data in a text file.
Demo and download by clicking this link:

Click this link to launch the demo and download the source. :
PB2Web : Demo PHP
Do not hesitate to enter your nickname and location.
Note: This is only a demonstration. Php code is not secure and ugly

.