Page 1 of 2

Sports Text Manager Game (Wrestling)...

Posted: Mon Mar 13, 2017 8:38 am
by kap1987
Hello, I´m trying to build a Wrestling Manager on my own in Livecode. Up to now I was able to import a Database of Personal Data (id, Name, Age and other) to a Data Grid on a card called "Squad".

Now I would like to have the Data Grid with only the names of the persons --> i disabled the other colums (e.g. age). CHECKED!

Now I would like to have one of the two following options:

1. when i highlight a persons name (1 row only) in the data grid of card "squad" it builds up and opens a new card based on the id of the person automatically.
for example the personal data is: id=2 | name=Mr.X | Age=25
when I ihighlight this person in the data grid, a new card (for id=2) opens and on this there are fields that show the other data (age,...)

2. when i highlight a persons name (1 row only) in the data grid of card "squad" it builds up and opens a new pop up in the same card based on the id of the person automatically.
for example the personal data is: id=2 | name=Mr.X | Age=25
when I ihighlight this person in the data grid, a pop up for id=2 opens and on this there are fields that show the other data (age,...)

is one of the two or are both options possible?

Thx for your help!

Re: Sports Text Manager Game (Wrestling)...

Posted: Wed Mar 15, 2017 1:29 pm
by Klaus
Hi kap1987,

1. welcome to the forum! :D

2. Yes, both options are doable with Livecode!
Please find attached a small (and simple) stack that will get you started.

I will move this thread to the "Beginners" forum, since this is not really a GAME question.
Maybe that's why noone responded so far...


Best

Klaus

Re: Sports Text Manager Game (Wrestling)...

Posted: Wed Mar 15, 2017 6:33 pm
by kap1987
Thx Klaus... This helps me very much and it works just fine.

1. Is there a way to edit the text in the "new" fields and save this back to database?

2. Is there a way to use your script for an image (as an avatar) for the highlighted person in the list as well?
so if i highlight a name in the list not only the data of the database is filled into external fields but one field is for the avatar of the highlighted name and switched with highlighting an other name?
For Example a persone called "Kurt Wagner"... Is there a way to show an image, named "kurtwagner.jpg" if the image is saved before in a specific folder on phone memory and if "Kurt Wagner" is highlighted in the list?

3. I have a list of e.g. 20 names. I was able to let me scroll the list even on an android phone. but i had to expand the vertical pixel of the field containing the data. on my list i tried 5000px so everything is definetely inside. (the visible scrolling field is only 800px high). in this example there is much space left after the last name on the list (because of the 5000px height)... is it possible for the script to automatically stop scrolling when the list ends, so that the last name on the list is the bottom data on the field to show?

Re: Sports Text Manager Game (Wrestling)...

Posted: Wed Mar 15, 2017 6:57 pm
by Klaus
Hi kap1987,
kap1987 wrote:1. Is there a way to edit the text in the "new" fields and save this back to database?
sure, unlock the fields and add a "closefield" handler to them to update the database using the ID in fld "ID".
If this is the INDEX of the record in the database, THIS field should of course stay locked and not editable! :D
kap1987 wrote:2. Is there a way to use your script for an image (as an avatar) for the highlighted person in the list as well?
so if i highlight a name in the list not only the data of the database is filled into external fields but one field is for the avatar of the highlighted name and switched with highlighting an other name?
For Example a persone called "Kurt Wagner"... Is there a way to show an image, named "kurtwagner.jpg" if the image is saved before in a specific folder on phone memory and if "Kurt Wagner" is highlighted in the list?
Sure, add an image object to your card and set its filename to the appropriate image.
This may not work on mobile due to sandboxing restrictions!

Or "fill" the image with an image that is stored in the database.
kap1987 wrote:3. I have a list of e.g. 20 names. I was able to let me scroll the list even on an android phone. but i had to expand the vertical pixel of the field containing the data. on my list i tried 5000px so everything is definetely inside. (the visible scrolling field is only 800px high). in this example there is much space left after the last name on the list (because of the 5000px height)... is it possible for the script to automatically stop scrolling when the list ends, so that the last name on the list is the bottom data on the field to show?
Please check these lessons: http://lessons.livecode.com/m/4069 for more solutions to mobile tasks.

And check these stacks to get more of the basics of Livecode, which are ESSENTIAL:
http://www.hyperactivesw.com/revscriptc ... ences.html

Best

Klaus

Re: Sports Text Manager Game (Wrestling)...

Posted: Fri Mar 17, 2017 11:25 am
by kap1987
Thx again...


I was able to built a pop up, to show the data of the highlighted name in the data grid...

but i have a problem with scrolling the grid...

when the pop up opens scrolling of the grid in the back is still possible. how can i disable the scrolling, only when the pop up is in front?

Re: Sports Text Manager Game (Wrestling)...

Posted: Fri Mar 17, 2017 12:41 pm
by Klaus
Hi kap1987,

maybe you should give some more info about your "layout" of the app.

What do you mean with "pop up"? A separate stack? A group on the card?
Eventually you can put the "pop up" in front of your datagrid?
Or simply hide the datagrid while the "pop up" is visible?


Best

Klaus

Re: Sports Text Manager Game (Wrestling)...

Posted: Fri Mar 17, 2017 12:51 pm
by kap1987
oh ok... The "pop up" is just a group...

i have the data grid centered on the card. when pushing a button called "show profile", the group "profile" pops up (is shown as a higher layer on the data grid and conceals almost the whole data grid). it shows the information data of the name highlighted in the data grid. so the pop up group is places above the data grid in the layer list.

on the pop up there is nothing to scroll cause it fits the screen card size (with small edge of about 40px on all 4 sides, where you can see the edge of the highlighted grid).
if you swipe your finger vertical on the pop up, the lines in the data grid of the back scroll.

the card with the pop up is built like this: https://storage.googleapis.com/material ... ation2.png

Re: Sports Text Manager Game (Wrestling)...

Posted: Fri Mar 17, 2017 1:23 pm
by Klaus
Hi kap1987,

AHA! This is for mobile, a VERY important info! 8)

Hm, I don't develop for mobile, but looks like there is no property you can set to disable a native scrollter.
Native controls are some kind of OVERLAY on top of all Livecode controls so you can scroll even if you do not see the datagrid.

Maybe this will help?
...
mobilecontrolset "you scroller name here", "visible", FALSE
...
At least worth a try :D

If not I don't see any other way than do DELETE the scroller before popping up the "pop up"
and create it anew when the "pop up" diappears.


Best

Klaus

Re: Sports Text Manager Game (Wrestling)...

Posted: Tue Mar 21, 2017 11:00 pm
by kap1987
Thx again...


I have another question for building a slide in menu like it is standard today on almost all android apps. (i mean, a click on the "hamburger-menu" opens a menu from the left (outside the screen)

Now I want to open this menu with a swipe from the edge of the screen. I just found this but i don´t understand the script to use it for my app...

is there a simple way to just swipe in a menu from the edge of a screen (1080x1920)? i tried it with "move group.... to location" but then it will always moves complete into the screen and into the locations mentioned in the script.
i would like to swipe the menu with my finger - pixel by pixel. so when i swipe only about 100 px the menu will swipe 100 px into the screen but when i release the screen with my finger it will snap back to the outside of the screen. but when i swipe for about 540 px (half of the screen width) it will snap the menu to the center of the screen.

Re: Sports Text Manager Game (Wrestling)...

Posted: Wed Mar 22, 2017 11:01 am
by Klaus
Hi kap1987,

well, this is really advanced stuff and I cannot come up with this just like that, sorry! :D
Maybe you should post this again in the iOS or Android forum.


Best

Klaus

Re: Sports Text Manager Game (Wrestling)...

Posted: Tue Mar 28, 2017 8:09 am
by kap1987
Ok no Problem...

Another Problem with SQLite Database and Imagesupport...

I was able to build my own database with sqlite admin. i was also able to load and show the data into a data grid of my card. but when i store an image in my database with sqlite admin (in a field as BLOB) and update the database on the card livecode crashes (runtime error... )

Any guesses why and how to solve it?


Or is there a way to load the image from the phone?
i was able to change the data shown in fields when highlighting different rows in the data grid.... is it possible to load an external image from phone storage into a placeholder image when a specific row in the data grid is highlighted...
e.g. : i have a person called "abyss" in the data grid... is it possible to load an image from phone storage called "abyss.jpg"? on highlighting the name in the data grid?
when i highlight another name (e.g. "alberto") it changes the image on the card to "alberto.jpg"? so i need a kind of "placeholder" in the imagename which is the id or name of the person in the data grid...

Re: Sports Text Manager Game (Wrestling)...

Posted: Wed Mar 29, 2017 7:21 pm
by kap1987
Is ist possible to filter the data shown in a data grid.

i´ve built a sqlite database with some columns.

i want to load all the data into a variable and show them on the data grid --> checked

i used: put revDataFromQuery(tab,return,gtDatabaseID,"SELECT * FROM wrestler") into gWrestler

Now i can see all columns i made visible in the data grid.


but how can i filter to show only the persons of the list with a special kind of text sign in a single column?

example:
Column roster says "RAW" or "Smackdown"

how can i filter the data grid to only show persons with "RAW" written in the column roster? (important: the other columns should stay in the database so i can send them to another field if i want to) ;)

Re: Sports Text Manager Game (Wrestling)...

Posted: Wed Mar 29, 2017 8:38 pm
by Klaus
Hi Kap,

sure you can do this in Livecode, but this is more a SQL question! :D

Code: Select all

...
put "SELECT * from wrestler WHERE roster = 'RAW' OR roster = 'Smackdown'" into tSQL
put revDataFromQuery(tab,return,gtDatabaseID,tSQL") into gWrestler
...
Please check this site: https://www.w3schools.com/sql/default.asp
Since I am not too familiar with SQL I always consult this page if in doubt! :D
Or is there a way to load the image from the phone?
Due to sandboxing you do not have access to any data outside of your app on mobile!
You could let the user choose an image by using "mobilepickmedia..." but that will probably not help in this case.

What script do you use to fetch the "blob" data from the database and to put this into your image object in your datagrid?


Best

Klaus

Re: Sports Text Manager Game (Wrestling)...

Posted: Thu Mar 30, 2017 8:14 am
by kap1987
Thx. Now the filter works... I just forgot the ' ' before and after the word :(

I put the image into SQlite Database as Blob. In sqlite Admin i can see that it is saved into the field.

in Livecode i used:
put gDataWrestler["image"] into field "profileimage" of group "profilewrestler"

for understandiung:
gDataWrestler = the table in the database
image = column in the database containing the picture
profileimage = the field that should show the picture (i tried it with an image instead of the field, but the same error occurs)
profilewrestler = a pop up on the card where the image and other info is shown


i also tried a test version:
on mouseUp
if field "id" is an integer then
put revOpenDatabase("sqlite", "C:\Users\kap19\OneDrive\EWR App\Neuer Ordner\runrevemails.sqlite", , , , ) into tID
put revQueryDatabase(tID, "SELECT * FROM images WHERE id=" & field "id" & ";") into tRecordSet
put revDatabaseColumnNamed(tRecordSet, "image", tImage) into tError #tImage contains data, tError contains errors
set the text of image "imagecontainer" to tImage
revCloseCursor tRecordSet
revCloseDatabase tID
else
answer "Please enter an ID!"
end if
end mouseUp
but when i try to open a picture stored in the database (column = "images"; fieldtype=BLOB) saved via sqlite admin, livecode crashes on runtime error.

As I read there might be a problem with livecode to read BLOB data which is not encoded and stored via livecode itself into the database. Do you know anything about it?

Re: Sports Text Manager Game (Wrestling)...

Posted: Thu Mar 30, 2017 10:06 am
by Klaus
put gDataWrestler["image"] into field "profileimage" of group "profilewrestler"
... into FIELD ...? :shock:
Sure you did not use an IMAGE object?