Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - ampos

#41
WebOS

In the site http://reviewtomail.com/ you can enter your app id and email and they will sent you a daily report with all your WebOS App review.

Free

iOS

AppAnnie is a great service: get detailed reports of your iOS downloads, chart positions, comments and much, much more. Get a daily report by email also.

http://www.appannie.com

This service is a MUST for anu iOS developer out there.


Android

AppAnnie has been updated to support Android numbers also.
#42
Digital Photo Frame reaches is 5th update in WebOS and just has been released for Android.

It sold 200 copies in 1 month for WebOS, as it is the best solution to turn your device into a complete Digital Photo Frame.

This app is just "fire&forget", as there is nothing to touch when launched. You photos will be shown in random (or straight) order, along a very convenient clock & date. Also, the photo album or photo name can be displayed.

Use our (almost) complete file explorer to choose multiple folders with your photos, change the speed or the delay. Even better, you can navigate your photos with your finger.

#43
My app is "dock compatible" just by adding to the .json file the tag ""dockMode": true"

But a user is asking me about quitting the app once it is not on the dock if launched from the doc :) autoquit.

He sent me this link:

https://developer.palm.com/content/resources/develop/the_mystical_art_of_exhibition.html

But I dont understand anything :)

Anyone can bring me a hand? Thank you.
#44
I use NETWEBEND to launch website/search/email in my app (as "rate me" buttons and so)

In iOS, the app is not ended/closed but sent back. On WebOS it is closed.

Can it be fixed, or is there a way to use somekind of NETWEBEND without the "end"?

:)
#46
On my new app, I have this function:

function bla:
   local pix[],tpix[]

   dim pix[4000*3000] //number can vary
   dim tpix[1000*700]

   code...
endfunction

And this function is called every 10 seconds, during HOURS, so it is called a ton of times.

Could it drive to problems?


My app, the photoframe, has been working without problems for several hours, but lately it is having problems.

First it was using loadsprite (0 or 1) to load photos, and I think it was also with 3.0.4. Working fine.

But from a week or so, I found the touchpad with the following msg: "the app photoframe has closed unexpectly" (or something similar). The loadmemsprite function was not implemented.

Amazing, yesterday I found the TP running with Android, what means that the whole unit was reseted, as Android is the default OS when powered on.

Currently I have added a log file, to try to find if there is an error or it was just simply a malformed jpg file.

Is glb_on_quit called when the app closes due a internal error? Is there a way to know the error that closed the app?
#47
I get this error when accesing the online user manual:

QuoteWarning: simplexml_load_file() [function.simplexml-load-file]: /var/kunden/webs/glbasicabc/glbasic/help/glbasic_e.xml:56: parser error : xmlParseCharRef: invalid xmlChar value 28 in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: 10;
<2>?ERROR</2> 

Generate an  in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: /var/kunden/webs/glbasicabc/glbasic/help/glbasic_e.xml:56: parser error : xmlParseCharRef: invalid xmlChar value 29 in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: #60;/2> 

Generate an error : preprocessor error in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: /var/kunden/webs/glbasicabc/glbasic/help/glbasic_e.xml:56: parser error : xmlParseCharRef: invalid xmlChar value 28 in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: 10;
<2>?WARNING</2>

Generate a  in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: /var/kunden/webs/glbasicabc/glbasic/help/glbasic_e.xml:56: parser error : xmlParseCharRef: invalid xmlChar value 29 in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: /2>

Generate a warning : preprocessor warning : in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /var/kunden/webs/glbasicabc/glbasic/xmlhelp.php on line 128

#48
The function LOADSPRITEMEM does not like values as absolute numbers, gives an error at compile runtime


Works:
Code (glbasic) Select
ok=LOADSPRITEMEM("myfile.jpg",w,h,pix[])

Error:
Code (glbasic) Select
ok=LOADSPRITEMEM("myfile.jpg",2000,1000,pix[])
#49
I need to use loadspritemem with jpg files, but this command needs the image size.

So, before loading the jpg file I need to know his size in pixels.

I found a doc at http://stackoverflow.com/questions/2517854/getting-image-size-of-jpeg-from-its-binary and it seems it is not that easy (it is not stored on the jpg header).

So I found this piece of code at http://www.64lines.com/jpeg-width-height but I have no idea how to insert it into GLB.

Anyone can help?

Code (glbasic) Select
//Gets the JPEG size from the array of data passed to the function, file reference: http://www.obrador.com/essentialjpeg/headerinfo.htm
static char get_jpeg_size(unsigned char* data, unsigned int data_size, unsigned short *width, unsigned short *height) {
   //Check for valid JPEG image
   int i=0;   // Keeps track of the position within the file
   if(data[i] == 0xFF && data[i+1] == 0xD8 && data[i+2] == 0xFF && data[i+3] == 0xE0) {
      i += 4;
      // Check for valid JPEG header (null terminated JFIF)
      if(data[i+2] == 'J' && data[i+3] == 'F' && data[i+4] == 'I' && data[i+5] == 'F' && data[i+6] == 0x00) {
         //Retrieve the block length of the first block since the first block will not contain the size of file
         unsigned short block_length = data[i] * 256 + data[i+1];
         while(i<data_size) {
            i+=block_length;               //Increase the file index to get to the next block
            if(i >= data_size) return false;   //Check to protect against segmentation faults
            if(data[i] != 0xFF) return false;   //Check that we are truly at the start of another block
            if(data[i+1] == 0xC0) {            //0xFFC0 is the "Start of frame" marker which contains the file size
               //The structure of the 0xFFC0 block is quite simple [0xFFC0][ushort length][uchar precision][ushort x][ushort y]
               *height = data[i+5]*256 + data[i+6];
               *width = data[i+7]*256 + data[i+8];
               return true;
            }
            else
            {
               i+=2;                              //Skip the block marker
               block_length = data[i] * 256 + data[i+1];   //Go to the next block
            }
         }
         return false;                     //If this point is reached then no size was found
      }else{ return false; }                  //Not a valid JFIF string
         
   }else{ return false; }                     //Not a valid SOI header
}
#50
Getjoyx&y&z are always returning 0.

Perhaps since 3.0.4 as it worked before.
#52
En Canal Sur a las 22:40 ponen la peli "el discipulo". Yo soy el que en los primeros 5 minutos sale gritando "Romanooooos!".
:enc: :enc: :enc: :enc:

podeis verla online desde la web de canalsur.es
#53
Yes, it is (again) a UNIVERSAL SCREEN SIZE SCALING SYSTEM   :S

I had the idea to port ALL gfx commands to use polyvectors and be resolution independents, so we can code to just 1 resolution and will work at all platforms, using the (almost) fastest polyvector system, targetting any target resolution with/without aspect ratio.

To start, I have made the initialization function and ported the very first function, DRAWSPRITE. If one of each us made 1 function, it could be done real soon. I will copy your functions to this first post to keep it updated. Please, post the function you are going to do before so no one else does the same.

HOW-TO USE

In your proyect, you only need to change the CONSTANTS x_orig and y_orig with the values of the screen size you are coding for (the size that will draw at size 1:1).

Call the "z_init" function at the start of your program. If you dont want it to keep the aspect ratio of your graphics, call it with value=0

That's all, just call the functions as if they were original GLBasic commands, same syntax. (Note that I added the "color" param to the function as optional; as it is going to be used by polyvector anyway, just put it!)

You call the functions with "absolute" values, as if they were for a fixed screen size. The commands themself will scale your graphics to the device resolution, leaving black borders for unused screen.

In many console games (I recall some Wii examples) they draw a background that fills the entire screen and the game is drawn really in a center 4:3 "window" in the center of the screen. An iPAD (1024x768) resolution game will look similar in a 800x480 android device. If you do not want the screen to be filled with black borders, just do this:

Code (glbasic) Select
CLEARSCREEN -1 //if the entire screen is going to be redrawn, do not clear it before!
...your game here
SC()   //use this instead of showscreen

function SC:  //this routine will fill your entire screen with a nice background
   showscreen
   stretchsprite background,0,0,x_res,y_res
endfunction


Example:
   x_orig=1024;z_drawsprite id,512,0 will be always drawn at the center of the screen, even at a 320x240 screen resolution.

Code (glbasic) Select
// --------------------------------- //
// Project: ProjectoZ
// Start: Tuesday, October 25, 2011
// IDE Version: 10.118

GLOBAL x_offset,y_offset //offset to add to X&Y to display correctly
GLOBAL x_res,y_res //X&Y real screen size
GLOBAL x_zoom,y_zoom //zoom to scale sprites and so
GLOBAL x_orig=768,y_orig=1024 //the screen size our app is designed for
GLOBAL single_sheet=0 //1 IF all sprites in a single sheet

FUNCTION initZ: keep_ratio=0
LOCAL z

GETSCREENSIZE x_res,y_res

x_zoom=x_res/x_orig
y_zoom=y_res/y_orig

IF keep_ratio<>0
z=MIN(x_zoom,y_zoom)
x_zoom=z
    y_zoom=z
x_offset=(x_res-(x_orig*x_zoom))/2
y_offset=(y_res-(y_orig*y_zoom))/2
IF x_offset<1 THEN x_offset=0
IF y_offset<1 THEN y_offset=0

ENDIF

init_SC()

ENDFUNCTION

FUNCTION z_drawsprite: num%,x%,y%,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2

GETSPRITESIZE num,sx,sy

x1=x_offset+(x*x_zoom)
x2=sx*x_zoom
y1=y_offset+(y*y_zoom)
y2=sy*y_zoom

// STRETCHSPRITE num,x1,y1,x2,y2

STARTPOLY num
POLYVECTOR x1,y1,0,0,color
POLYVECTOR x1,y1+y2,0,sy,color
POLYVECTOR x1+x2,y1+y2,sx,sy,color
POLYVECTOR x1+x2,y1,sx,0,color
ENDPOLY

ENDFUNCTION

FUNCTION z_drawanim: num%,frame%,x%,y%,w%,h%,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2,ancho,alto,xa,ya

GETSPRITESIZE num,sx,sy

x1=x_offset+(x*x_zoom)
x2=w*x_zoom
y1=y_offset+(y*y_zoom)
y2=h*y_zoom

ancho=sx/w;alto=sy/h
ya=INTEGER(frame/ancho)*h
xa=MOD(frame,ancho)*w

// STRETCHANIM num,frame,x1,y1,x2,y2

IF single_sheet=0 THEN STARTPOLY num
POLYVECTOR x1,y1,xa,ya,color //TL
POLYVECTOR x1,y1+y2,xa,ya+h,color //BL
POLYVECTOR x1+x2,y1+y2,xa+w,ya+h,color //
POLYVECTOR x1+x2,y1,xa+w,ya,color
IF single_sheet=0
ENDPOLY
ELSE
POLYNEWSTRIP
ENDIF
ENDFUNCTION

FUNCTION z_rotozoomanim: num%,frame%,x%,y%,w%,h%,ang,size,color=0xFFFFFF
LOCAL sx,sy,x1,y1,x2,y2,ancho,alto,xa,ya,x3,x4,y3,y4,xcos,ysin,xs,ys,sw,sh

GETSPRITESIZE num,sx,sy
sw=w;sh=h

x=x_offset+(x*x_zoom)-(((w*size)-w)/2)
w=w*x_zoom*size
y=y_offset+(y*y_zoom)-(((h*size)-h)/2)
h=h*y_zoom*size
INC x2,x1;INC y2,y1

ancho=sx/sw;alto=sy/sh
ya=INTEGER(frame/ancho)*sh
xa=MOD(frame,ancho)*sw

h=h/2
w=w/2
INC x,w
INC y,h

x1 = x
y1 = y
x2 = x
y2 = (y + h)
x3 = (x + w)
y3 = y
x4 = (x + w)
y4 = (y + h)

xcos = tCOS(ang)
ysin = tSIN(ang)

x1 = x - (xcos * w) - (ysin * h)
y1 = y - (xcos * h) + (ysin * w)

x2 = x - (xcos * w) + (ysin * h)
y2 = y + (xcos * h) + (ysin * w)

x3 = x + (xcos * w) - (ysin * h)
y3 = y - (xcos * h) - (ysin * w)

x4 = x + (xcos * w) + (ysin * h)
y4 = y + (xcos * h) - (ysin * w)

SELECT single_sheet
CASE 0
STARTPOLY num
POLYVECTOR x1, y1, xa, ya,color //TL
POLYVECTOR x2, y2, xa, ya + sh,color //BL
POLYVECTOR x4, y4, xa + sw, ya + sh,color //BR
POLYVECTOR x3, y3, xa + sw, ya,color //TR
ENDPOLY
CASE 1
POLYVECTOR x2, y2, xa, ya + sh,color //BL
POLYVECTOR x1, y1, xa, ya,color //TL
POLYVECTOR x4, y4, xa + sw, ya + sh,color //BR
POLYVECTOR x3, y3, xa + sw, ya,color //TR
POLYNEWSTRIP
ENDSELECT

ENDFUNCTION

FUNCTION z_print: t$,x,y,font=100,centered=1,zoom=1,color=0xFFFFFF,underline=0,italic=0
LOCAL fx,fy,l,c$,tx,ty,dx,dy,fxz,fyz,t1,t2,t3,t4,tl
LOCAL line_width=2 //width of the underline line in pixels at zoom 1 (100%)
LOCAL outline=2 //width of the outline in underline in pixels at zoom 1 (100%)
LOCAL und_pos=.9 //vertical position of underline (in % of Font Y size)
LOCAL ital_ang=.5 //inclination of font (in % of font X size)

GETSPRITESIZE font,fx,fy
fx=fx/16;fy=fy/16 //change to fy/8 if you dont use full charset fonts
        fxz=fx*zoom*x_zoom;fyz=fy*zoom*y_zoom
        tl=LEN(t$,1)*zoom*x_zoom

x=x_offset+(x*x_zoom)
y=y_offset+(y*y_zoom)

DEC x,(LEN(t$,1)*zoom*centered*x_zoom)/2

IF underline=1   
t1=line_width*(zoom*y_zoom);IF t1<1 THEN t1=1
t2=fxz/4
t3=fyz*und_pos
t4=outline*(zoom*x_zoom);IF t4<1 THEN t4=1

STARTPOLY   //this can be changed with a call to z_drawline...
POLYVECTOR x-t2-t4,y+t3-t4,0,0,0
POLYVECTOR x-t2-t4,y+t3+t1+t4,0,0,0
POLYVECTOR x+t2+tl+t4,y+t3+t1+t4,0,0,0
POLYVECTOR x+t2+tl+t4,y+t3-t4,0,0,0
ENDPOLY

STARTPOLY
POLYVECTOR x-t2,y+t3,0,0,color
POLYVECTOR x-t2,y+t3+t1,0,0,color
POLYVECTOR x+t2+tl,y+t3+t1,0,0,color
POLYVECTOR x+t2+tl,y+t3,0,0,color
ENDPOLY

ENDIF

    italic=italic*zoom*fx*ital_ang*x_zoom
STARTPOLY font,2
FOR n=0 TO LEN(t$)-1
c$=MID$(t$,n,1)
l=ASC(c$)

ty=ASR(l,4)
tx=INTEGER(MOD(l,ty*16))
dx=tx*fx
dy=ty*fy

POLYVECTOR x,y+fyz,dx,dy+fy,color //BL
POLYVECTOR x+italic,y,dx,dy+1,color //TL
POLYVECTOR x+fxz,y+fyz,dx+fx,dy+fy,color //BR
POLYVECTOR x+fxz+italic,y,dx+fx,dy+1,color //TR
POLYNEWSTRIP
INC x,LEN(c$,1)*zoom*x_zoom
NEXT
ENDPOLY
ENDFUNCTION

FUNCTION z_drawline: x1,y1,x2,y2,color=0xFFFFFF,width=1
LOCAL w=(x2-x1)*x_zoom
LOCAL h=(y2-y1)*y_zoom

x1=x_offset+(x1*x_zoom)
y1=y_offset+(y1*y_zoom)
x2=x_offset+(x2*x_zoom)
y2=y_offset+(y2*y_zoom)

width=width*x_zoom
glLineWidth (width)
DRAWLINE x1,y1,x2,y2,color
glLineWidth(1)

// STARTPOLY
// POLYVECTOR x1,y1,0,0,color
// POLYVECTOR x1+w,y1+h,0,0,color
// POLYVECTOR x1+w+1,y1+1+h,0,0,color
// POLYVECTOR x1+1,y1+1,0,0,color
// ENDPOLY

ENDFUNCTION

FUNCTION z_drawrect: x,y,w,h,color=0xFFFFFF

x=x_offset+(x*x_zoom)
y=y_offset+(y*y_zoom)
w=w*x_zoom
h=h*y_zoom

STARTPOLY
POLYVECTOR x,y,0,0,color
POLYVECTOR x,y+h,0,0,color
POLYVECTOR x+w,y+h,0,0,color
POLYVECTOR x+w,y,0,0,color
ENDPOLY

ENDFUNCTION

INLINE
#define OGL ::
typedef float           GLfloat;
ENDINLINE

INLINE
} extern "C" { void __stdcall glLineWidth( GLfloat width );; }; namespace __GLBASIC__ {
ENDINLINE
FUNCTION glLineWidth: width
INLINE
OGL glLineWidth(width);
ENDINLINE
ENDFUNCTION


INLINE
} //  + + + A T T E N T I O N + + +
// int __a__ needs to be a n^2 value.
// Higher values give better precision
// but larger lookup tables as well!

const unsigned int __a__ = 131072 ;
const DGInt __b__ = (360.0 / __a__) ;
const unsigned int __c__ = (__a__ - 1) ;
DGInt _sin_tbl_[__c__] ;
DGInt _cos_tbl_[__c__] ;
const DGInt __d__ = (1 / __b__);
namespace __GLBASIC__ {
ENDINLINE

FUNCTION init_SC:
INLINE
for(int i=0; i < __c__; ++i)
{
_sin_tbl_[i] = SIN( i * __b__ ) ;
_cos_tbl_[i] = COS( i * __b__ ) ;
}
ENDINLINE
ENDFUNCTION // INIT_SIN_COS_TABLES

// ------------------------------------------------------------- //
// ---  TCOS  ---
// ------------------------------------------------------------- //
FUNCTION tCOS: x // in degrees
INLINE
return _cos_tbl_[ (int)(x * __d__) & __c__ ] ;
ENDINLINE
ENDFUNCTION // TCOS



// ------------------------------------------------------------- //
// ---  TSIN  ---
// ------------------------------------------------------------- //
FUNCTION tSIN: x  // in degrees
INLINE
return _sin_tbl_[ (int)(x * __d__) & __c__ ] ;
ENDINLINE
ENDFUNCTION // TSIN






HOW TO MAKE FUNCTIONS

I think that the z_drawsprite function is easy enough to understand, but to clarify how to calculate target resolutions

Initial X & Y coordinates are calculated with

Code (glbasic) Select
x1=x_offset+(x*x_zoom)
y1=y_offset+(y*y_zoom)


You have to use, mandatory, x_offset & y_offset, as the init function will set this values correctly if the user wants or not "aspect ratio lock"

The target sprite sizes are easily calculated too with

Code (glbasic) Select
x2=sx*x_zoom
y2=sy*y_zoom


being sx and sy, current sprite size.

0.01 - Initial release
        - DRAWSPRITE
0.02 - PRINT (with attributes)
0.03 - DRAWLINE
          DRAWRECT
          Added a "+1" on z_print text print part to fix gfx glitches
0.04 - DRAWANIM (it needs in the function the size of the anim frame)
          ROTOZOOMANIM (it needs in the function the size of the anim frame
          Uses tCOS and tSIN for faster SIN/COS
          Updated PRINT to use POLYNEWSTRIP
          The variable SINGLESHEET can be used to use POLYNEWSTRIP when drawing multiple sprites from a single sheet.
          The DRAWLINE command has the option WIDTH, through OpenGL itself.
0.05- Minor update. Removed some old lines. Add more explanations for use.
0.06- RotoZoomAnim had a bug
#54
Using the "polyprint" code by AlienMenace, I have upgraded my current print function.

zprint: t$,x,y,font=100,centered=1,zoom=1,color=0xFFFFFF,underline=0,italic=0
Prints a text on screen with many optional parameters)
t$ text to be printed
x,y x&y coordinates of the text to be printed. Regardless of the zoom, the text is always printed starting at x,y coordinates.
font=100 (optional) font to be used. It has to be loaded previously as animated sprite using loadanim "name"... By default, it uses sprite id 100. I just discovered that the font has to be loaded also as font, or the kerning will fail and funny text will be printed.
centered=0/1 (optional) Choose 1 if you want the text centered on your X coordinate.
zoom (optional) the size of the text to be printed (.5=1/2 smaller, 2=2x times bigger,...)
color (optional) to change the color of the text, using the format RGB (red, green, blue). ON some mobile devices it can be slow or not work at all.
underline=0/1 (optional) Choose 1 if you want your text underlined.
italic (optional) Type any value to draw your text in italics. Although the value should be 1, you can change it to have a bigger or smaller angle.

Code (glbasic) Select
FUNCTION zprint: t$,x,y,font=100,centered=1,zoom=1,color=0xFFFFFF,underline=0,italic=0
LOCAL fx,fy,l,c$,tx,ty,dx,dy,fxz,fyz
LOCAL line_width=2 //width of the underline line in pixels at zoom 1 (100%)
LOCAL outline=2 //width of the outline in underline in pixels at zoom 1 (100%)
LOCAL und_pos=.9 //vertical position of underline (in % of Font Y size)
LOCAL ital_ang=.5 //inclination of font (in % of font X size)

GETSPRITESIZE font,fx,fy
fx=fx/16;fy=fy/16 //change to fy/8 if you dont use full charset fonts
        fxz=fx*zoom;fyz=fy*zoom

DEC x,(LEN(t$,1)*zoom*centered)/2

IF underline=1
STARTPOLY
POLYVECTOR x-(fxz/4)-(outline*zoom),y+(und_pos*fyz)-(outline*zoom),0,0,0    //remove "-(fxz/4)" if you dont want the underline to be larger than text
POLYVECTOR x-(fxz/4)-(outline*zoom),y+(und_pos*fyz)+((outline+line_width)*zoom),0,0,0
POLYVECTOR x-(fxz/4)+(outline*zoom)+(LEN(t$,1)+fx/2)*zoom,y+(und_pos*fyz)+((outline+line_width)*zoom),0,0,0
POLYVECTOR x-(fxz/4)+(outline*zoom)+(LEN(t$,1)+fx/2)*zoom,y+(und_pos*fyz)-(outline*zoom),0,0,0
ENDPOLY
STARTPOLY
POLYVECTOR x-(fxz/4),y+(und_pos*fyz),0,0,color
POLYVECTOR x-(fxz/4),y+(und_pos*fyz)+(line_width*zoom),0,0,color
POLYVECTOR x-(fxz/4)+(LEN(t$,1)+fx/2)*zoom,y+(und_pos*fyz)+(line_width*zoom),0,0,color
POLYVECTOR x-(fxz/4)+(LEN(t$,1)+fx/2)*zoom,y+(und_pos*fyz),0,0,color
ENDPOLY
ENDIF

        italic=italic*zoom*fx*ital_ang

FOR n=0 TO LEN(t$)-1
c$=MID$(t$,n,1)
l=ASC(c$)

ty=INTEGER(l/16)
tx=INTEGER(MOD(l,ty*16))
dx=tx*fx
dy=ty*fy

STARTPOLY font
POLYVECTOR x+italic,y,dx,dy,color
POLYVECTOR x,y+fyz,dx,dy+fy,color
POLYVECTOR x+fxz,y+fyz,dx+fx,dy+fy,color
POLYVECTOR x+fxz+italic,y,dx+fx,dy,color
ENDPOLY

INC x,LEN(c$,1)*zoom
NEXT
ENDFUNCTION


I should put the STARTPOLY and ENDPOLY commands outside the loop to make the draw faster, but I don't get it. If someone can fix it, I will update this post.

edit 1.- precalculates fxz=fx*zoom, and changed all (fx*zoom) for fx. Same for fy. Moved out of the loop the italic calculation.
#55
I though I was crazy, as I was unable to find how to fold a function...

If you have Line Numbers ON, the fold/unfold does not work.

(Can we have some Fkey (perhaps F2) to fold/unfold current function?)
#56
#57
GLBasic - en / Nested TYPEs
2011-Oct-20
In my next proyect, I need a file list of 3rd depth :)

1-Drive
2-Folder
3-File

Each list can have any number of elements, and have various values, so I am going to use types. Each "list" (child?) belong only to his previous parent.

But I have never used nested types (types inside types), so I have a few doubts

-Can a type be defined inside a type that belongs to another type?
   a[1].b[4].c[6], for example?

-Should I define the types in inverse order?

type a3:
   name
   path$
   id
endtype

type a2:
   name
   id
   files[] as a3
endtype

type a1:
   name
   id
   folders[] as a2
endtype

-How do I get some element in the 3rd level?
  print drive[n].folder[m].file
  • .name?

    -How do I do a foreach...next loop for the bottom child?
       foreach n in drive[10].folder[3].file[]?




#58
You have to thanks MSX for this awesome work, not me. I'm just the guilty of this crappy translation.

Any comments about the code are welcomed. Comments about the translation, please, sent me a PM.


PART I: CREATING A PAYPAL TESTING ACCOUNT


We need to create a test account for Paypal. There is a website by PayPal for this purpose, without real money (but fake one). The URL is the same but adding "sandbox": www.sandbox.paypal.com instead of www.paypal.com

The first step is to sign up at https://developer.paypal.com and login.

Then we will create 2 accounts, one as Seller and one as Buyer. These are the accounts we will use for our testing. Choose Create a preconfigured account.



Fill it and create the seller account. Then again the buyer account with $500 for the tests.

To check this accounts status (payments, purchases,...) choose Test accounts in the main page and a list with our accounts will be listed. Choose the one you want to see and click at Enter Sandbox Test Account. You will be redirected to a page similar to the standard PayPal website, but with "Test Site" on the top.


PART II: SETTING OUR SELLER ACCOUNT


It's time to set our seller account. At first, we will do it with our Seller Test Account but once we see it is working, do it with your real seller account.

Choose My account -> Profile -> Website Payment Preferences

Auto return: On
Return URL: http://your domain/donative.php
Payment Data Transfer: On
Encrypted Website Payment: Off
Paypal Account optional: On
Contact Telephone number: Off
Express Checkout Settings: No

And Save

Again, Profile -> Instant Payment Notifications Preferences -> Edit Settings

Notification URL http://your_domain/paypal_ipn.php
Receive IPN messages On

And Save

Ok, we have our seller account ready to receive payments and get notifications to our website.


PART III: IT'S MySQL & PHP TIME!


This part needs a little knowledge of MySQL databases and FTP. The first step is to create a database in our sever (with any name). This is done through the control panel of our website server. It's pretty intuitive, so I will not extend on it.

The database will be used to store information like buyer's device id and some other values, in case of reclamation.

We will create the following fields (you can change the names, but remember to change them in the PHP files):

Code (glbasic) Select

# Column Type Collation Null Default Extra
1 id int(11)         No None       AUTO_INCREMENT
2 transid text     latin1_swedish_ci No None
3 name text latin1_swedish_ci No None
4 date int(11) No None
5 status  text     latin1_swedish_ci No None
6 email   text     latin1_swedish_ci No None
7 city   text     latin1_swedish_ci No None
8 currency text     latin1_swedish_ci No None
9 amount  tinytext latin1_swedish_ci No None
10 paypal text latin1_swedish_ci No None
   

The field "paypal" will be used to store all the info sent by PayPal, in case there is an error or reclamation.

Now it is PHP time!

The first archive will be the one called by GLBasic.

paypal.php
Code (glbasic) Select
<?php
$form5
='<form name="_donations" id="donate" action="https://www.sandbox.paypal.com/es/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="your seller email">
<input type="hidden" name="item_name" value="Name of item">
<input type="hidden" name="item_number" value="'
.$_GET["id"].'">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="'
.$_GET["am"].'"><p align="Center"><br/><br/><font size="5"><b>Processing, please wait...</b></font></p></form><body onload="document._donations.submit();">';

echo 
$form5;
?>


In business put the email you created in PayPal as seller.

In item_name place the name of the item/service offered; it will be shown in buyer's screen, something like remove bra from girls.

In currency_code put USD for US Dollars, EUR for euros,... I use USD always, but it is up to you. It could be modified to use the buyer's currency, but this value has to be passed to GLB... forgot for today :)

This was the program that will do from GLBasic to Paypal. When we call this file, we have to pass some values: item_number (device's id) and amount (price of the item).


Now we are going to create the php file that will receive the transaction data, that also will store all the data in the database if the bought was ok.

paypal_ipn.php
Code (glbasic) Select
<?php
$link=mysql_connect("host","user_name","password");
mysql_select_db("BD_Name",$link);  

$req 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
    
$value urlencode(stripslashes($value));
    
$req .= "&$key=$value";
}

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " strlen($req) . "\r\n\r\n";
$fp fsockopen ('www.sandbox.paypal.com'80$errno$errstr30);
 
if($_POST['payment_status']=='Completed' || $_POST['payment_status']=='Processed') {

$query="insert into paypal (name, transid, date, status, email, city, currency, amount, paypal) VALUES ('".$_POST['first_name']." ".$_POST['last_name']."', '".$_POST['item_number']."', ".time().", '".$_POST['payment_status']."', '".$_POST['payer_email']."', '".$_POST['address_state']."', '".$_POST['mc_currency']."', '".$_POST['payment_gross']."','".$req."')";
$result=mysql_query($query,$link);

}

?>


To configure this file you will need to change these two lines with your own data:


   $link=mysql_connect("host","user_name","password");
   mysql_select_db("nombre_BD",$link);


In host put the host of your DB, usually localhost, although it could vary in some servers. In username and password put the name & password of the user of the database. In DB_Name the name of the database created :)


And now, the PHP file used by PayPal when the buyer finish his transaction.

donative.php
Code (glbasic) Select
<?php
// read the post from PayPal system and add 'cmd'
$req 'cmd=_notify-synch';

$tx_token $_GET['tx'];
$auth_token "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " strlen($req) . "\r\n\r\n";
$fp fsockopen ('www.sandbox.paypal.com'80$errno$errstr30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp$header $req);
// read the body data
$res '';
$headerdone false;
while (!
feof($fp)) {
$line fgets ($fp1024);
if (
strcmp($line"\r\n") == 0) {
// read the header
$headerdone true;
}
else if (
$headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}

// parse the data
$lines explode("\n"$res);
$keyarray = array();
if (
strcmp ($lines[0], "SUCCESS") == 0) {
for (
$i=1$i<count($lines);$i++){
list(
$key,$val) = explode("="$lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname $keyarray['first_name'];
$lastname $keyarray['last_name'];
$itemname $keyarray['item_name'];
$amount $keyarray['payment_gross'];

echo (
"<table align='center'><tr><td align='center'><h3>Thank you for your purchase!<br>¡Gracias por su donación!</h3>");

echo (
"<b>Payment Details/Detalles del pago</b><br>\n");
echo (
"<table><tr><td align='left'><li>Name/Nombre: <i>$firstname $lastname</i></li>\n");
echo (
"<li>Item/Servicio: <i>$itemname</i></li>\n");
echo (
"<li>Amount/Cantidad: <i>$amount </i>USD</li>\n</p></td></tr></table></td></tr></table>");
echo (
"");
}
else if (
strcmp ($lines[0], "FAIL") == 0) {
echo (
"<table align='center'><tr><td align='center'><h3>Transaction failed!<br>¡Error in the transaction!!</h3></td></tr></table>");

}


Here we read the data sent by PayPal regarding the transaction, that will help us to inform the buyer if all was ok or there was an error. Many data are received, although I only show name, item bought and price. If you need something else, just ask.

It is important to fill the following data correctly

$auth_token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

or nothing will be received. This data can be got in our PayPal account, in My account -> Profile -> Website Payment Preferences in the field called Payment Data Transfer (optional), in Identity Token.

Once the payment has finished, we only need the PHP that will query our DB to check if our device's id is authorized. We will send back to GLBasic a value if it does or not, so we can check if the item is available or not in the program.

Something like this:

auth.php
Code (glbasic) Select
<?php
$ID
=$_GET['id'];

$link=mysql_connect("host","user_name","password");
mysql_select_db("BD_name",$link);
$query=sprintf("SELECT * FROM paypal WHERE transid='%s'",
addcslashes(mysql_real_escape_string($ID),'%_'));
$result=mysql_query($query$link);
$numero_rows mysql_num_rows($result);

if (
$numero_rows>0)
echo "1";
else 
        echo 
"0";

?>


The PHP file gets the device's id to check, and returns 0 if it does not exist, or 1 it does.

We a bit more knowledge of PHP we can improve this routine, as currently is very basic. It could be "easy" to change the call to our database to somewhere else and always return "1", so the queries would be always authorized. For the use I do (just extra donations) I don't care a lot, but for next projects, instead of "1" I will return the device's id encrypted (using the same algorithm as GLBasic, I think there is a php file that does this somewhere), so when GLBasic receives the authorization, it could be decrypted and checked against PLATFORMINFO$("ID"), giving authorization if the two values are equal, making it a more secure system, as the answer could not be supplanted as the seed is unknown. Do not use the same seed in all your programs, as the same answer could validate any application for the same device.


PART IV: CLOSING THE CIRCLE


Ok, it is almost done. Just join all together in GLBasic. How? First we have to call paypal.php with the needed values for the transaction, device's id and amount to pay:

NETWEBEND "http://your domain/paypal.php?id="+PLATFORMINFO$("ID")+"&am="+amount_to_pay

This will call our server, that will call Paypal with the correct values; once the payment is done, PayPal sent back the result of the transaction to our server (file paypal_ipn.php) that will check if all was ok, and if it was, fill our database with the results and answer PayPal with "data received". PayPal will set the transaction as finished, going back to our server at the file donative.php that will ask PayPal all the data of the transaction and the final result. If ok, we will show to the user the data we want to (I am showing name, item purchased and amount), and that all was fine (or not!) and the girl's bra were removed.

Now we need in GLB to check if the user/app is authorized using this call:


AUTH=NETWEBGET$("your_domain","/auth.php?id="+PLATFORMINFO$("ID"),80,512)


IF AUTH=1
    // The bras are removed!
ELSE
    // No, no bras for you. Show me the money!
ENDIF




PARTE V: CONCLUDING


All of this is orientative; PHP code can be modified for more security or to suit your needs, although as it is here it is working. Do not touch the code that calls PayPal servers, as it is delicate and could stop working, although you could work with the received data and improve it. If you need PHP help I could.

IMPORTANT: we have been working with PayPal's Sandbox, so the money is fake. Once all is working fine, you just need to replace the fields in the php files with your true ones (email & auth token). Also you will have to remove all the sandbox word from the domain names (www.sandbox.paypal.com -> www.paypal.com.

NOTE: The device's id as returned by PLATFORMINFO$("ID") should be shown to the user, so he can sent it to us, so we can activate his device in "manual mode" (or just our friend's devices).

...THE END
#59
Can we have a SWAP command? It interchange the value of 2 variables:

Code (glbasic) Select
function swap: a,b
   local temp
   temp=a
   a=b
   b=temp
endfunction


=D

Yeah, Im lazy
#60
I ahve sent to HP my app, but they said it can not find photos.

I would like you to test it on your device.

It will read photos from 3 places:

-Camera folder, not on mobile devices (in fact, inside the /DCIM folder)

-Facebook. Only if your device has downloaded previously FB photos. Only tested this in TP.

-Photos inside a folder called "photos" in the main directory of the device. Example: g:/photos/myphoto.jpg. Please, use photos lower than 4096x4096 on TP. It can read photos inside folders also.

The app has work on my TP and my Pre2, should work on any other WebOS device but Pixi.

Thank you for your feedback.