Program Template

Post Reply
User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Program Template

Post by rbytes » Wed Feb 20, 2019 10:54 pm

*** Updated today, March 2nd *** If you downloaded it earlier, please refresh your copy now.

This program was written for those who are learning Smart Basic, but more experienced coders may find it useful, as I do. It is a a template for a graphics-oriented program, and also a functional program. Rather than starting from scratch, if you have an idea for a graphics program you can immediately start coding the actions, instead of spending hours to set up the graphics screen, build the interface, etc. All of those things are already done for you.

FIrst, run the program as downloaded. It loads an image and lets you move it up and down or side to side with sliders. You can also load a new image using the load button.

But the Program Template can easily be adapted. You can keep the buttons, rename them, delete some or add some.
You can do the same with the two sliders and two fields. I suggest for now that you don't change any code in the file loader function. You can change the name of the app (program) in the drawinfobar function to your preferred name.

The main areas to work on first are:

1. The init subroutine (highlighted in yellow). It sets your default values and creates the interface.

2. The main program loop (highlighted in cyan). All decisions and actions are made in this loop. First, remove the actions that are there now. Then try coding your own drawing - maybe some shapes or text in different colors as a starting project. Or come up with your own unique graphics idea. Please post it here if you create a version you like.

Let me know if you find this shell useful, or have a request for some other function.

I have attached the image used by the program, CalcBG.jpg. Put it in the same folder as the program.

CalcBG.jpg
CalcBG.jpg (1.05 MiB) Viewed 381 times

There are three screen shots below the code, taken after moving the image with the two sliders.

Code: Select all

/*
Program Template
rbytes, February 2019
A shell program you can use to develop
your own graphics programs. 
**************************************************
Works with iPad, iPhone
1. Fill in any required information shown
   in square brackets.
2. Delete any code lines with settings that are not
   needed, or change the settings to suit you.
   (You can leave this step until last).
3. Delete any lines that display interface
   objects you don't want (buttons, sliders, lists
   fields).
4. Enter your program within the program loop area
   (cyan-colored background, although you can change that too!)
*/

'*********** The Program Shell Starts Here **********************

/*
[Program Title (with optional version number)]
[Your Name], [Date of Completion]
[Simple Description of Program]
**************************************************
[Versions, showing Changed/Added/Deleted Features]
[Devices Supported]
[Instructions]
*/

OPTION BASE 1                  ' values start at 1, not 0
SET TOOLBAR OFF                ' standard toolbar off
OPTION ANGLE DEGREES           ' needed only if you are using angles
OPTION IMAGE POS CENTRAL       ' image is positioned by its center
SET ORIENTATION LANDSCAPE      ' horizontal rotation of your display screen
SET BUTTONS CUSTOM             ' nicer-looking buttons
laun$=LAUNCHER$ ()             ' identifies how program is launched
dev$=DEVICE_TYPE$()            ' identifies the device you are using
GET SCREEN SIZE sw,sh          ' measures screen width and height

iphonetest=0                   ' = 1 for testing iphone display on your ipad
IF iphonetest THEN
  sw=568              ' set this value to your iPhone's screen width
  sh=320              ' set this value to your iPhone's screen height
  dev$=""
ENDIF

' rw and rh will adjust your display size to the device being used.

rw=sw/1024!rh=sh/768  ' set these integers to match your iPad's screen size


' initialize variables, set display, create interface objects 
' (sliders, buttons, fields, etc.)

GOSUB init            
' look for the init: label for this subroutine after the main program loop


DRAW COLOR 1,1,1    ' set draw color to white
GOSUB reset         ' prepare the display
drawinfobar         ' show the top information bar

'c' main program loop
DO SLOWDOWN         ' SLOWDOWN keeps processor from running at 100% when idling


' this slider moves the image up and down. Since its output value is always a number from 0 to 1, we multiply that by screen height to get the total distance range desired

  IF sc(V$) THEN                          ' sc is a function for SLIDER_CHANGED()
    GRAPHICS CLEAR 1,1,1
    vert=INT(sh*SLIDER_VALUE(V$))         ' vertical position of image
    FIELD V$ TEXT "  Vertical: "&vert
    DRAW IMAGE Image1$ AT horiz,vert SCALE rw

    ' each time anything is drawn, the screen is refreshed (redrawn)
    ' because of the REFRESH OFF command, it is not automatically refreshed at any other time
    ' this technique stops any flickering of the image as it is moved.
    REFRESH

  ENDIF


' this slider moves the image sideways. Since its output value is always a number from 0 to 1, we multiply that by screen height to get the total distance we want

  IF sc(H$) THEN
    GRAPHICS CLEAR 1,1,1
    horiz=INT(sw*SLIDER_VALUE(H$))       ' horizontal position of image
    FIELD H$ TEXT "  Horizontal: "&horiz
    DRAW IMAGE Image1$ AT horiz,vert SCALE rw
    REFRESH
  ENDIF


  ' this button resets the image and sliders to center position

  IF bp(R$) THEN                        ' bp is a function for BUTTON_PRESSED()
    gosub reset
  ENDIF


  ' this button is at the very top left corner of the screen. It takes you to the debug screen, where you can check the contents of variables

  IF BUTTON_PRESSED("debug") THEN DEBUG PAUSE
  

  ' this routine updates the top infobar when any values change (time, battery level, charging on/off)

  IF CURRENT_MINUTE()<>oldmin OR BATTERY_LEVEL()<>oldlev OR BATTERY_STATE()<>oldstat THEN
    oldmin=CURRENT_MINUTE()
    oldlev=BATTERY_LEVEL()
    oldstat=BATTERY_STATE()
    drawinfobar
  END IF


' this button calls the file requester to choose a new image.

  IF bp(L$) THEN
    GRAPHICS CLEAR .5,.5,.5
    REFRESH
    path$=""             ' you can change this to a folder you prefer
    corr=50*rh           ' corrects an unwanted horizontal shift in toolbar
    fname$=getfname$(350*rw,20*rh,220*rw,254*rh,1,path$)
    if fname$<>"" and fname$<>"cancel" THEN
      IF FILE_EXISTS(fname$) THEN
      Image1$=fname$
      ENDIF
    ENDIF
    GOSUB RESET
  ENDIF


  ' this button saves the screen image and exports it to Photos. If you prefer not
  ' to export it, comment out the ALBUM EXPORT line with an apostrophe '

  IF bp(S$) THEN
    NOTES SET "88:v127tc3e3$f3g3$"
    NOTES PLAY
    datename$()
    GRAPHICS SAVE 0,0,sw,sh TO "progshell "&datename$
    ALBUM EXPORT "progshell "&datename$
  ENDIF
 

  ' this button ends the program. You can use either the Quit button at lower screen, or the X button in the top right corner

  IF bp(Q$) or bp("quit2") THEN
    ender:
    IF laun$="desktop" THEN
      IF FILE_EXISTS("/launch") THEN
        RUN "/-Launch.sb"
      ELSE
        EXIT
      ENDIF
    ENDIF
    END
  END IF
 
UNTIL 0       ' this is the end of the program loop. UNTIL 0 means forever. The loop will never stop unless you press Quit or X to end the program

''

' ************** Start of Subroutines ***************

'You can jump into these subs from anywhere in the program. We use subs for
'routines that occur more than once, to avoid repeating the same code.


'y' this sub initializes the program variables and creates the interface
' (buttons, sliders, fields, etc.)

init:
Image1$="CalcBG.jpg"
R$="reset"
V$="vert"
H$="horiz"
L$="load"
S$="save"
Q$="quit"


' put the program into graphics mode so images can be displayed

GRAPHICS
GRAPHICS CLEAR 1,1,1
PAUSE .2            ' needed for the screen to set to white before refresh is shut off


' set the drawing color to black. This will be the text color on the buttons

DRAW COLOR 0,0,0


' create two sliders
' notice that for sliders, buttons and fields (and any other items drawn on screen), we multiply the locations and sizes by either rw or rh. They scale the output to fit either an iPad or iPhone screen.

SLIDER H$ VALUE .5 AT 45*rw,640*rh SIZE 300*rw       ' width
SLIDER V$ VALUE .5 AT 680*rw,640*rh SIZE 300*rw      ' height


' create two fields that display the horizontal and vertical position of the image
' remember, the image is being moved by its center, so the startin location will be
' in the exact center of the screen.

FIELD H$ TEXT "  Vertical: "&fsize AT 120*rw,600*rh SIZE 160*rw,30*rh RO
FIELD H$ FONT COLOR 1,1,1
FIELD H$ FONT SIZE 18*rw
FIELD H$ BACK COLOR .3,.3,.3

FIELD V$ TEXT "  Horizontal: "&size1 AT 745*rw,600*rh SIZE 160*rw,30*rh RO
FIELD V$ FONT COLOR 1,1,1
FIELD V$ FONT SIZE 18*rw
FIELD V$ BACK COLOR .3,.3,.3


' create the four buttons (you can re-purpose them)
' note that button height is multiplied by rw rather than rh
' this creates taller buttons on the iPhone that are easier to press

SET BUTTONS FONT SIZE 20*rw
BUTTON R$ TEXT "RESET" AT 300*rw,700*rh SIZE 80*rw,30*rw   ' reset button
BUTTON L$ TEXT "LOAD" AT 400*rw,700*rh SIZE 80*rw,30*rw    ' load button
BUTTON S$ TEXT "SAVE" AT 500*rw,700*rh SIZE 80*rw,30*rw    ' save button
BUTTON Q$ TEXT "QUIT" AT 600*rw,700*rh SIZE 80*rw,30*rw    ' quit button

REFRESH OFF          ' stops the screen from being continually refreshed. If you comment out this line, you'll see that when the image is moved, it flickers. 

RETURN               ' end of the init (initialize) subroutine


' this sub centers the image on the screen and sets both sliders to their midpoints

reset:
  GRAPHICS CLEAR 1,1,1
  SLIDER V$ VALUE .5
  SLIDER H$ VALUE .5
  horiz=INT(sw*SLIDER_VALUE(H$))         ' horizontal position of image
  vert=INT(sh*SLIDER_VALUE(V$))          ' vertical position of image
  FIELD V$ TEXT "  Vertical: "&vert
  FIELD H$ TEXT "  Horizontal: "&horiz
  DRAW IMAGE Image1$ AT sw/2,sh/2 SCALE rw
  REFRESH
RETURN

' end of init subroutine

'' 

'************** Functions *****************

' a shortcut for the command BUTTON_PRESSED(a$).

DEF bp(a$) = BUTTON_PRESSED(a$)


' a shortcut for SLIDER_CHANGED(a$)

DEF sc(a$) = SLIDER_CHANGED(a$)


' generates a unique PNG image name including the current date and time, so that you dont overwrite previous saved images

DEF datename$()
  fd$=CURRENT_YEAR()&"-"
  fd$&=STR$(CURRENT_MONTH())&"-"
  fd$&=STR$(CURRENT_DATE())&" "
  fd$&=STR$(CURRENT_HOUR())&":"
  if len(STR$(CURRENT_MINUTE()))=1 then fd$&="0"
  fd$&=STR$(CURRENT_MINUTE())&".png"
  .datename$=fd$
END DEF


'b'
' a file requester - can search anywhere in your Smart Basic folder and choose a file to load or save. Can name a new file for saving, too.

DEF getfname$(x,y,w,h,type,path$)
OPTION BASE 1

' create a new page for the file requester, and hide the original page
PAGE "request" SET ! PAGE "request" SHOW
PAGE "" HIDE

'type = 1 for load, 2 for save
max=500 ! SET LISTS CUSTOM
trans=0
DIM directs$(max),FILES$(max), dirfile$(2*max)
FILL COLOR 1,1,1 ! DRAW COLOR 0,0,0
DRAW ALPHA 1 ! FILL ALPHA 1
sw=.sw ! sh=.sh
rw=.rw ! rh=.rh

' if this is an iPhone or iPod
IF rw<1 THEN
  bord=4 ! bord2=3          ' adjust border for iPhone or iPod
ELSE
  bord=0 ! bord2=0          ' adjust border for iPad
ENDIF

' prepare the correct helping hint for loading or saving
IF type=1 THEN
  fb$="Select file"&CHR$(10)&CHR$(10)&"Click OK to load it"&CHR$(10)&CHR$(10)&"Click CANCEL to escape"
ELSE
  fb$="Select or name file"&CHR$(10)&CHR$(10)&"Click OK to save it"&CHR$(10)&CHR$(10)&"Click CANCEL to escape"
ENDIF
IF x+w>sw-10 THEN x=sw-w-10 ! xbot=x+w
IF y+h>sh-10 THEN y=sh-h-10 ! ybot=y+h*1.6
SPRITE "fbrow" SCAN x-2,y-2,w+4,h+4

' if this is the first time the function has been called, create the interface
IF NOT previously THEN

  ' this field creates the black border around the feedback field
  FIELD "underfb" TEXT "" AT x*.395-2,y*1.6-3 SIZE x*.41+sw*.16+4-(x*.4-2),y+h*.31+sh*.32-y*1.6-6+bord
  FIELD "underfb" BACK COLOR 0,0,0

  ' this field on the left side of the screen gives helpful hints
  FIELD "feedback" TEXT fb$ AT x*.4,y*1.62 SIZE sw*.16+2,sh*.395 RO ML
  FIELD "feedback" FONT SIZE 20*.rw

  ' this field creates the black border around the file/folder list
  FIELD "underff" TEXT "" AT x-3,y-3 SIZE xbot-x*.737+bord2,ybot*.8-y+6 RO
  FIELD "underff" BACK COLOR 0,0,0

  ' this field creates a white background under the file/folder list
  FIELD "underff2" TEXT "" AT x,y SIZE xbot-x*.752,ybot*.8-y RO

  ' this field creates a black line below the file/folder list
  FIELD "lineff" TEXT "" AT x,y*13.5 SIZE xbot-x*.75,3 RO
  FIELD "lineff" BACK COLOR 0,0,0

  ' this field is the filename entry field below the list
  FIELD "namer" TEXT fil$ AT x+w*.05,y*1.4+h*1 SIZE w*1.2,h*.18
  FIELD "namer" FONT SIZE 20*.rw
 FIELD "namer" FONT NAME "Arial-BoldMT"

  ' this field provides a notice if a file is being saved
  FIELD "alert" TEXT "SAVING" AT sw/2-TEXT_WIDTH("SAVING")/2.4, sh/2 SIZE 180*rw,50*rh
  FIELD "alert" HIDE
  FIELD "alert" FONT SIZE 40*rh
  FIELD "alert" BACK ALPHA .7

  ' this field is a filter, controlling which files are displayed
  FIELD "filter" TEXT filter$ AT x*2.005,y+h*.08 SIZE sw*.216,sh*.05
  FIELD "filter" FONT SIZE 20*.rw
  FIELD "filtertext" TEXT " Filter:" AT x*2.005,y-9*(rw+rh)/2 SIZE sw*.216,sh*.05 RO
  FIELD "filtertext" FONT SIZE 20*.rw
  FIELD "filtertext" BACK ALPHA 0
  FIELD "filtertext" FONT COLOR 1,1,1

  SET BUTTONS FONT SIZE 20*(rw+rh)/2
  DRAW COLOR 0,0,0

  ' these are the buttons that control selection
  BUTTON "cancel" title "CANCEL" AT x*2.2,y+h*.8 SIZE sw*.1,sh*.07
  BUTTON "ok" title "OK" AT x*2.2,y+h*1.05 SIZE sw*.1,sh*.07
  BUTTON "up" title "UP" AT x*2.2,y+h*.55 SIZE sw*.1,sh*.07
  BUTTON "root" title "ROOT" AT x*2.2,y+h*.3 SIZE sw*.1,sh*.07

  FILL ALPHA 0
  ' this is the "crosshairs" button for clearing text from the "namer" field
  ' the outline of the button must be hidden
  BUTTON "clrfld" TEXT CHR$(8855) AT x*1.775,y+h*1.04
  FILL ALPHA 1

ENDIF

filter2$=""
fil$=""
label1: DIR$=""

label2: 
IF DIR$>"" THEN path$=path$ & DIR$ & "/"

' create two arrays, one for folders, one for files
label25:
DIR path$ LIST DIRS directs$,n1
DIR path$ LIST FILES FILES$,n2

label3:
IF n1 THEN
  FOR i=1 TO n1 ! dirfile$(i)="DIR: " & directs$(i) ! NEXT i
END IF

label4:
ntot=n1
IF n2 THEN
  FOR i=1 TO n2
    IF filter$="" OR filter$="filter" OR INSTR(FILES$(i),filter$)>=0 OR (type=1 AND INSTR(FILES$(i),filter2$)>=0) THEN
      ntot+=1 ! dirfile$(ntot)=FILES$(i)
    END IF
  NEXT i
END IF
IF ntot=0 THEN ! ntot=1 ! dirfile$(1)="" ! END IF
DIM temp$(ntot)
FOR i=1 TO ntot ! temp$(i)= dirfile$(i) ! NEXT i

' if this is the first time the file requester has been called,
' create the interface objects. Otherwise, skip this step.
IF NOT previously THEN

  ' create and update the file/folder list
  SET LISTS FONT SIZE 20*(rw+rh)/2
  LIST "fsel" TEXT temp$ AT x+2,sh*.03 SIZE xbot-x*.75-3,h*.97
ELSE

  ' just update the file/folder list
  LIST "fsel" TEXT temp$
ENDIF

.path$=path$ ! .fil$=fil$

label5:

' if CANCEL button pressed, enable cancelling the file requester
IF bp("cancel") THEN
  ret$="cancel" 
  GOTO label6
END IF

' if crosshairs button is pressed, clear the name field
IF bp("clrfld") THEN FIELD "namer" TEXT ""

' if OK button is pressed, return the selection and close the file requester
IF bp("ok") THEN
  IF FIELD_TEXT$("namer")<>"" THEN fil$=FIELD_TEXT$("namer")

' check if either the filename or pathname are null
  IF fil$>"" THEN
    IF path$ > "" THEN
     ret$=path$ & fil$
    ELSE
     ret$ = fil$
    END IF
    GOTO label6
  END IF
END IF

IF filter$<>filterhold$ THEN
  filter$=FIELD_TEXT$("filter")
  GOTO label4
END IF
  filterhold$=FIELD_TEXT$ ("filter")

' if a new name is typed into the name field, deselect the file list
IF FIELD_CHANGED("namer") THEN
  fil$=FIELD_TEXT$("namer")
  LIST "fsel" SELECT -1
  GOTO label4
ENDIF

' if UP button pressed, display the folder one step up in the folder hierarchy
IF bp("up") THEN 
  IF RIGHT$(path$,1)="/" THEN path$=LEFT$(path$,LEN(path$)-1)
  FOR k=LEN(path$) TO 1 STEP -1
    IF MID$(path$,k,1)="/" THEN BREAK
    NEXT k
  IF k THEN ! path$=LEFT$(path$,k) ! GOTO label25 ! END IF
END IF

' if ROOT button pressed, display the root folder
IF bp("root") THEN
  path$="/" ! DIR$=""
  GOTO label25
END IF

' if an entry is selected in the file/folder list
sel=LIST_SELECTED("fsel")
IF sel>0 THEN
  IF sel>n1 THEN
     
     ' a file has been selected; choose the file
     IF NOT trans THEN FIELD "namer" TEXT dirfile$(sel)
     trans=1
     IF FIELD_CHANGED ("namer") THEN trans=0
     IF sel<>tempsel THEN trans=0
     IF FIELD_TEXT$("namer")="" THEN
        fil$= dirfile$(sel)
     ELSE
        FIELD "namer" TEXT dirfile$(sel)
        fil$=FIELD_TEXT$("namer")
     ENDIF
     tempsel=sel
    GOTO label5
    ELSE
      ' a folder has been selected; display the folder
      DIR$=directs$(sel) ! GOTO label2
    END IF
  END IF
GOTO label5

label6:

' cancel the file requester
IF ret$ = "cancel" THEN
  previously=1
  PAGE "" SET
  PAGE "" SHOW
  PAGE "request" HIDE
  RETURN ret$
ENDIF

SPRITE "fbrow" AT xtop-2,ytop-2 ! SPRITE "fbrow" STAMP
DRAW SIZE 1

' if a file is being saved, show an alert
IF type=2 THEN
  FIELD "alert" SHOW
  PAUSE 1
  FIELD "alert" HIDE
ENDIF
.path$=path$
previously=1   ' set the flag indicating that the file requester has been used

' close the requester page and show the original page
PAGE "" SET       
PAGE "" SHOW
PAGE "request" HIDE
RETURN ret$    ' return the filename to the line that called this function
END DEF

''
'g'
' custom top toolbar

DEF drawinfobar()
draw size 1
if .act then corr=50
tb$="Battery"
FILL ALPHA 0
sw=.sw!sh=.sh
rw=.rw ! rh=.rh
aj=sw/5
ypos=-4
SET BUTTONS CUSTOM
SET BUTTONS FONT SIZE 18*rw

' show device info
sv$=DEVICE_TYPE$()&" with iOS "&SYSTEM_VERSION()

' show time
ampm$="AM" ! hr=CURRENT_HOUR()
MIN$=STR$(CURRENT_MINUTE())
IF LEN(MIN$)=1 THEN MIN$="0"&MIN$
IF hr>11 THEN ampm$="PM"
IF hr>12 THEN hr=hr-12
IF hr=0 THEN hr=12
tm$=STR$(hr)&":"&MIN$&" "&ampm$
tx=sw/2-TEXT_WIDTH(tm$)/2

' show app name
app$="Program Template V1"

' show battery condition
bat$=STR$(BATTERY_LEVEL())&"%"
lev=BATTERY_LEVEL()
tat=BATTERY_STATE ()
IF tat THEN tat$="~" ELSE tat$=""

' create all buttons first in black text. This will create a shadow effect
FILL COLOR 0,0,0
DRAW COLOR 0,0,0
BUTTON "sdebug" TEXT CHR$(8545) AT 5,ypos
BUTTON "sdev" TEXT sv$ AT int(sw*.05),ypos
BUTTON "stime" TEXT tm$ AT int(sw*.28),ypos
BUTTON "sprog" TEXT app$ AT int(sw*.4),ypos
BUTTON "sbat" TEXT bat$ AT int(sw*.7),ypos
BUTTON "stat" TEXT tat$ AT int(sw*.85),ypos
BUTTON "squit2" TEXT "X" AT int(sw*.96),ypos

' create all button in white, slightly up and to the left, to allow the black shadow effect to be seen.
DRAW COLOR 1,1,1
BUTTON "debug" TEXT CHR$(8545) AT 4,ypos-1
BUTTON "dev" TEXT sv$ AT int(sw*.05)-1,ypos-1
BUTTON "time" TEXT tm$ AT int(sw*.28)-1,ypos-1
BUTTON "prog" TEXT app$ AT int(sw*.4)-1,ypos-1
BUTTON "bat" TEXT bat$ AT int(sw*.7)-1,ypos-1
BUTTON "tat" TEXT tat$ AT int(sw*.85)-1,ypos-1
BUTTON "quit2" TEXT "X" AT int(sw*.96)-1,ypos-1

' draw battery symbol and make it a sprite
FILL ALPHA 1
DRAW ALPHA 1
DRAW SIZE 1
levfactor=rw*.39
SHADOW OFFSET 0,0
SPRITE TB$ BEGIN sw/8,20
FILL COLOR 0,0,0
DRAW COLOR 0,0,0
DRAW RECT 0,1 TO int(40*rw),int(14*rh)
FILL RECT 0,2 TO int(lev*levfactor),int(13*rh)
FILL RECT int(40*rw),4 TO int(44*rw),int(11*rh)
FILL COLOR 1,1,1
DRAW COLOR 1,1,1

DRAW SIZE 1
DRAW RECT 0,0 TO int(40*rw)-1,int(14*rh)-1
FILL RECT 0,1 TO int(lev*levfactor)-1,int(13*rh)-1
FILL RECT int(40*rw)-1,4 TO int(44*rw)-1,int(11*rh)-1
SPRITE TB$ END
SPRITE TB$ AT sw*.78,5*rh
SPRITE TB$ SHOW

DRAW COLOR 1,1,1
RETURN
end def
''
Attachments
81480D81-336B-4814-B2DE-DCC612C245DD.png
81480D81-336B-4814-B2DE-DCC612C245DD.png (3.84 MiB) Viewed 383 times
29CFA9E4-15A1-486C-A8EE-7C30BC455911.png
29CFA9E4-15A1-486C-A8EE-7C30BC455911.png (3.43 MiB) Viewed 383 times
C31078A4-1DE9-4149-8EB7-2760D5E0C71C.png
C31078A4-1DE9-4149-8EB7-2760D5E0C71C.png (4.35 MiB) Viewed 383 times
Last edited by rbytes on Sun Mar 03, 2019 6:36 am, edited 8 times in total.
####### Living the colorful life #######

PaulKnight
Posts: 18
Joined: Mon Jan 21, 2019 9:27 pm
My devices: iPhone SE
Flag: Great Britain

Re: Program Shell- Graphics

Post by PaulKnight » Fri Feb 22, 2019 10:03 am

Thanks rbytes!

This is just the type of code listing that really helps newbies like me! Seeing a working example with well commented code is just so helpful.

I can't wait to play with this when I get time next week. It's school half term here I the UK so no time for coding this week unfortunately.

Thanks again - much appreciated :-)

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Program Shell- Graphics

Post by rbytes » Fri Feb 22, 2019 2:39 pm

Thanks for the positive reaction, Paul. :D

A couple of fixes were needed to the code, and I will update it this morning.

Before you start working with the Shell , please download it again.

I just used it myself to create a new program called Text Cutter. My expected coding time was reduced by half.

I will post it tomorrow.
####### Living the colorful life #######

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Program Shell- Graphics

Post by rbytes » Fri Feb 22, 2019 5:08 pm

I have posted the updated code.
####### Living the colorful life #######

Chooch912
Posts: 9
Joined: Thu Apr 12, 2018 6:16 pm
My devices: iPad
Flag: United States of America

Re: Program Template

Post by Chooch912 » Mon Apr 01, 2019 5:53 pm

I am new to this- how do I get calcBG.jpg to the folder? When I click on the picture name nothing happens.

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Program Template

Post by rbytes » Mon Apr 01, 2019 6:29 pm

Press and hold on the image, and click Save Image from the popup menu. Once the image is in your Photos, run this one-line program to get it into your folder:

Code: Select all

ALBUM IMPORT "CalcBG.jpg"
Be sure you get the caps in the right places, because program names are case-sensitive.
####### Living the colorful life #######

Chooch912
Posts: 9
Joined: Thu Apr 12, 2018 6:16 pm
My devices: iPad
Flag: United States of America

Re: Program Template

Post by Chooch912 » Mon Apr 01, 2019 7:45 pm

Thank you very much!

I have it now!

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Program Template

Post by rbytes » Mon Apr 01, 2019 7:59 pm

OK. Let me know how it goes.
####### Living the colorful life #######

Chooch912
Posts: 9
Joined: Thu Apr 12, 2018 6:16 pm
My devices: iPad
Flag: United States of America

Re: Program Template

Post by Chooch912 » Mon Apr 01, 2019 8:10 pm

It worked perfectly! Because you gave me the code to get the image I was able to try another picture from my album. After changing the jpg name in your original code to match my photo name I ran the program to 100% satisfaction. I am amazed at what this SmartBasic can accomplish. Now I am going through your code line by line so I can understand all the various commands.

Thank you again for your help and patience!

User avatar
rbytes
Posts: 1972
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone X
iPad 4
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: Program Template

Post by rbytes » Mon Apr 01, 2019 8:12 pm

8-)
####### Living the colorful life #######

Post Reply